<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>产品定制</title>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <!--地图JS-->
    <script src="{$Think.config.httpFlag}{$Think.config.google_map_url}" async="async"></script>

    {if $is_domestic}
    <script src="/googlemap/amapPoint.js?v=0.03"></script>
    {else}
    <script src="/googlemap/googleMapPoint.js?v=0.01"></script>
    {/if}

    <script src="/googlemap/googleDirectionsService.js?v=2.0"></script>
    <script src="/googlemap/googleSearchPointLatLng.js?v=2.0"></script>
    <script src="/googlemap/googleMarkerPoint.js?v=2.0"></script>

</head>
<style>
    #nearbyPoiMap{
        height:400px;
    }
    ul,li{ padding:0;margin:0;list-style:none}
    .disabled { pointer-events: none; }
    .addclassify {
        display: inline-block;
        width: 80px;
        height: 30px;
        border: 1px solid #ccc;
        line-height: 30px;
        /*border-radius: 40px;*/
        text-align: center;
        cursor: pointer;
        background: #1E9FFF;
        color: #fff;
    }
    .addnumsty {
        /*background: #00a0e9;*/
        position: absolute;
        left: -11px;
        top: 10px;
        background: #1E9FFF;
        color: #fff;
        display: inline-block;
        width: 32px;
        height: 32px;
        border: 1px solid #1E9FFF;
        line-height: 32px;
        border-radius: 32px;
        text-align: center;
        cursor: pointer;
    }
    .layui-form-select .layui-edge {
        display: none;
    }
    .travelulone{
        display: flex;
        margin-bottom: 20px;
    }
    .addli{
        position: relative;
    }
    .deleteDay{
        position: absolute;
        right: 40px;
        top: 0;
    }
    .deleteDay i{
        color: red;
        font-size: 18px;
    }
    .ActionButton{
        z-index: 2;
        position: fixed;
        right: 20px;
        bottom: 140px;
        min-width: 125px;
    }
    .Actiondiv{
        /*display: inline-block;*/
        height: 38px;
        line-height: 38px;
        padding: 0 18px;
        background-color: #1E9FFF;
        color: #fff;
        white-space: nowrap;
        text-align: center;
        font-size: 14px;
        border: none;
        border-radius: 2px;
        cursor: pointer;
        -webkit-box-shadow: 0 2px 8px rgba(0,0,0,.15);
        box-shadow: 0 2px 8px rgba(0,0,0,.15);
        /*margin-bottom: 5px;*/
    }
    .layui-card-header{
        color: #ff7d00;
        font-weight: bold;
        font-size: 20px;
    }
    .layui-card-body{
        padding: 10px 50px;
    }
    .custom_input{
        width: 150px;
        border: 1px solid #cccccc;
        margin-left: 5px;
        margin-right: 50px;
        height: 30px;
        border-radius: 5px;
    }
    .material_data{
        /*border: 1px solid #CCCCCC;*/
        /*margin: 20px;*/
    }
    .unifybut{
        border: 1px solid #2196f3;
        text-align: center;
        margin-left: 40px;
        margin-bottom: 20px;
        width: 50px;
        height: 30px;
        line-height: 30px;
        border-radius: 5px;
        color: #fff;
        background:#2196f3;
    }
    .unifydelbut{
        border: 1px solid red;
        text-align: center;
        margin-left: 40px;
        margin-bottom: 20px;
        width: 50px;
        height: 30px;
        line-height: 30px;
        border-radius: 5px;
        color: #fff;
        background: red;
    }
    .unifybutadd{
        /*border: 1px solid #2196f3;*/
        text-align: center;
        /*margin-left: 12px;*/
        /*margin-bottom: 20px;*/
        width: 30px;
        height: 30px;
        line-height: 30px;
        /*border-radius: 2px;*/
        color: #fff;
        background: #ccc;
    }
    .layui-card-body span{
        font-size: 12px;
        line-height: 30px;
    }
    .layui-input{
        border-radius: 5px;
        height: 30px;
    }
    .layui-select-title{
        height: 30px;
    }
    .layui-form-label{
        line-height: 12px;
    }
    .deletePoi{
        margin-left: 80px;
        display: none;
    }
    .messdiv{
        height: 40px;
    }
    .messdiv:hover .deletePoi{display: block;}
    /*.messdiv:hover .detail-create-list*/
    /*{display: block;}*/
    .custom_input_s {
        width: 150px;
        margin-top: 0px;
        margin-right: 52px;
        margin-left: 13px;
        height: 30px;
        border-radius: 5px;
    }
    .layui-select-title input{
        border: 1px solid #ccc;
    }
    .partitionBox{
        display: flex;
    }
    /*右侧css*/
    .poi-detail{
        /*display: flex;*/
    }
    .poi-detail-item{
        font-size: 12px;
        padding: 8px;
        display: inline-block;
        vertical-align: top;
        border: 1px solid #dfdfdf;
        width: 30%;
    }
    .poi-detail-item-imgbox{
        max-width: 200px;
        position: relative;
        margin: 0 auto;
    }
    .poi-detail-item-imgbox img{
        width: 100%;
        height: 100px;
    }
    .poi-detail-item p{
        text-align: center;
        /*max-width: 200px;*/
        line-height: 18px;
        font-size: 12px;
    }
    .poi-detail-item p:nth-child(3)
    {
        font-size: 14px;
    }
    .poi_img_shadow {
        border: 3px solid #a7ff19;
        top: 0px;
        position: absolute;
        /* left: 167px; */
        width: 75px;
        display: none;

    }
    .poicheckeds{
        display:none;
    }
    .schedule_title{
        width: 100%;
    }
    .messdiv .layui-form-label{
        width: 20px;
    }
    .poi-p-list-box{
        height: 30px;
        padding: 0 5px;
        color: #999;
    }
    .poi-detail{
        /*padding:0 20px;*/
    }
    .btnfix{
        z-index: 999;
        position: fixed;
        right: 0px;
        bottom: 80px;
        min-width: 75px;
    }
    .btnfix img{
        width: 50px;
        height: 50px;
    }
    .poibtnshow{
        display: block;
        z-index:999;
    }
    .dragUp,.dragDown{
        height: 30px;
        line-height: 30px;
        background: #009688;
        text-align: center;
        color: #fff;
        margin-bottom: 3px;
        box-shadow: 0px 7px 7px -7px #5E5E5E;
    }
    .dragUpPricing,.dragDownPricing{
        height: 30px;
        line-height: 30px;
        /*background: #ff7d00;*/
        text-align: center;
        /*color: #fff;*/
        margin-bottom: 3px;
        box-shadow: 0px 7px 7px -7px #5E5E5E;
    }
    .rightPoiInfo_item{
        width: 100%;
        line-height: 30px;
        font-size: 13px;
        margin-bottom: 8px;
    }
    .rightPoiInfo_item label{
        float:left;
        font-weight: bold;
        width: 80px;
        text-align: right;
    }
    .rightPoiInfo_item>span{
        display: block;
        margin-left: 80px;
        color: #999;
    }
    .rightPoiInfo_item input{
        width: 500px;
    }
    .rightPoiInfo_item textarea{
        resize: none;
        width: 500px;
        height: 50px;
    }

    .ticketInfo_item{
        width: 100%;
        line-height: 30px;
        font-size: 13px;
        margin-bottom: 8px;
    }
    .ticketInfo_item label{
        float:left;
        font-weight: bold;
        width: 80px;
        text-align: right;
    }
    .ticketInfo_item>span{
        display: block;
        margin-left: 80px;
        color: #999;
    }
    #poi_name{
        font-weight: bold;font-size: 20px;margin-left:58px;
    }
    #poi_engname{
        color:#666;font-size: 13px;margin-left:58px;margin-bottom:10px;
    }
    #poi_introduce{
        max-height: 110px;
        overflow: scroll;
        overflow-x: hidden;
        border:1px #eee solid;
        padding: 8px;
    }
    .poi-detail-item-title{
        font-size: 24px !important;
        max-width:200px;
        line-height:30px !important;
    }
    .poi-detail-item-title1{
        font-size: 18px !important;
        max-width:200px;
        line-height:30px !important;
    }
    #rightmap{
        width:100%;
        height:300px;
        line-height: 30px;
        text-align: center;
        display: none;
        margin-bottom:20px;
    }
    #poi_introduce p span{
        margin:0;
    }
    #rightNewPOI .layui-input-inline{
        width: 60%;
    }
    .addressbox,.addressbox span{
        width:100%;
        background: #dfdfdf;
    }

    /*详细定制得样式*/
    .detail-custom-trip{
        display: inline-block;
        float: left;
        margin-right: 10px;
    }
    .layui-form-text{
        display: inline-block;
    }
    .detail-create{
        font-weight: bold;
        color: #fff;
        width: 50px;
        line-height: 1.5;
        display: inline-block;
        font-weight: 400;
        text-align: center;
        -ms-touch-action: manipulation;
        touch-action: manipulation;
        cursor: pointer;
        background-image: none;
        border: 1px solid transparent;
        white-space: nowrap;
        padding: 0 15px;
        font-size: 14px;
        border-radius: 4px;
        height: 28px;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-transition: all .3s cubic-bezier(.645,.045,.355,1);
        transition: all .3s cubic-bezier(.645,.045,.355,1);
        /*position: relative;*/
        color: rgba(0,0,0,.65);
        background-color: #fff;
        border-color: #ccc;
    }
    .detail-create span{
        font-weight: bolder;
    }
    .detail-create-list{
        list-style: none;
        display: none;
        outline: 0;
        position: absolute;
        padding: 0 !important;
        margin-top: 10px;
        width: 270px;
        text-align: center;
        background-color: #fff;
        border-radius: 4px;
        -webkit-box-shadow: 0 2px 8px rgba(0,0,0,.15);
        box-shadow: 0 2px 8px rgba(0,0,0,.15);
        background-clip: padding-box;
        z-index: 99999 !important;
    }
    .detail-create-list :hover{
        background: #e3e3e3;
    }
    .detail-create-list li{
        float: left;
        width: 82px;
        list-style: none !important;
        padding: 6px 0;
        margin: 4px !important;
        text-align: center;
        /*clear: both;*/
        font-size: 14px;
        font-weight: 400;
        color: rgba(0,0,0,.65);
        white-space: nowrap;
        cursor: pointer;
        -webkit-transition: all .3s;
        transition: all .3s;
        line-height: 22px;
    }
    .detailcustomshow{
        display: block;
    }
    /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
    ::-webkit-scrollbar
    {
        width: 5px;  /*滚动条宽度*/
        /*height: 5px;*/
    }

    /*定义滚动条轨道 内阴影+圆角*/
    ::-webkit-scrollbar-track
    {
        /*滚动条的背景区域的内阴影*/
        box-shadow:0px 1px 3px rgba(0,0,0,0.3) inset;

        /*滚动条的背景区域的圆角*/
        border-radius: 10px;

        /*滚动条的背景颜色*/
        background-color: #ddd;
    }

    /*定义滑块 内阴影+圆角*/
    ::-webkit-scrollbar-thumb
    {
        /*滚动条的内阴影*/
        box-shadow:0px 1px 3px rgba(0,0,0,0.3) inset;

        /*滚动条的圆角*/
        border-radius: 10px;

        /*滚动条的背景颜色*/
        background-color: #1E9FFF;
    }
    .border-d2{
        border: 1px solid #d2d2d2;
        padding: 8px;
    }
    .item-toggle,.hideDayMapBtn{
        float: right;
        color: #009688;
    }
    .uploadimgbox img{
        height: 60px;
    }
    .distance{
        height: 20px;
    }
    .distance-list{
        height: 20px;
        margin-top: -25px;
        margin-bottom: 7px;
    }
    .distance-list-car{
        font-size: 12px;
        color: #CCCCCC;
    }
    .allImgArr,#poiImgShow{
        width: 500px;
        min-height: 80px;
    }
    .allImgArr img{
        width: 90px;
        height: 60px;
    }
    .allImgArr{
        padding: 8px;
        background: #eee;
    }
    #poiImgShow i{
        color:red
    }
    .activeinput{
        background: #ffe9001a;
        /*border: 1px solid #ffe9001a;*/
    }
    .rightPoiInfo_item_submit{
        text-align: center;
        background: #009688;
        width: 30%;
        margin-top: 20px;
        /*margin-left: 22%;*/
    }
    .rightPoiInfo_item_span{
        width: 500px;
        text-align: center;
    }

    /*包车自驾样式*/
    .layui-Travel{
        padding: 10px;
        /*transform:rotateX(180deg);*/
    }
    /*滑块得高度*/
    .noUi-vertical .noUi-handle{
        top: 0;
        height: 17px;
        background: #1E9FFF;
    }
    /*交通配置样式*/
    .trafficCar{
        margin-left: 10px;
        font-size: 14px;
        color: #999;
        display: inline-block;
        width: 350px;
        min-height: 30px;
        /*padding: 1px 0;*/
        /*text-align: center;*/
        /*background: #eee;*/
        border-radius: 5px;
        border: 1px dotted #999999;
    }
    .layui-timeline-title{
        height:auto;
        min-height: 30px;
        line-height: 30px;
    }
    .changeReplaceDirector{
        width: 120px !important;
        text-align: center;
    }
    .changeReplaceDirector .layui-form-switch{
        margin-top:0;
        width:74px;
    }
    .changeReplaceDirector .layui-form-switch em{
        width: 60px;
    }
    .changeReplaceDirector .layui-form-onswitch i{
        left: 64px;
    }
    .trafficCar p{
        background: #ff98008f;
        /* width: 60px;
         height: 22px;
         line-height: 22px;
         padding: 0 5px;
         font-size: 12px;
         color: #fff;
         background: #1E9FFF;*/
    }
    .trafficCar_label{
        font-size:16px;
        padding: 0 8px;
    }
    .trans_type_close{
        float: right;
        margin-right: 20px;
        color:red;
    }
    .activetrafficCar{
        border: 2px solid #1E9FFF;
    }
    .box-price{
        /*width: 98.5%;*/
        min-height: 820px;
        margin:0 auto;
        padding: 0 5px;
        overflow-x: scroll;
    }
    /*去掉表格鼠标滑过得样式 .layui-table-hover*/
    .layui-table tbody tr:hover{
        background: #fff;
    }

    .table-input{
        margin-top:5px;
    }
    .table-input-text{
        margin-top:5px;
    }


    /* .switcherset{
         display: none;
     }*/
    .box-price ::placeholder{
        color: #CCCCCC;
    }
    .staff-not{
        text-align: center;
    }

    .inblock{
        display: inline-block;
    }
    .hotel-dealis{
        margin-top: 5px;
    }
    .hidden{
        display: none
    }
    #summaryPricingTable td input{
        width:70%;
        margin-left: 8px;
    }
    .money-unit-symbol{
        float: left;
        height: 30px;
        line-height: 30px;
        margin-right:8px;
    }
    .staff-have{
        display: none;
    }
    .symbolPrice{
        height: 30px;
        line-height: 30px;
        display: inline-block;
    }
    .money-unit-symbol-Price{
        display: inline-block;
        margin-right:8px;
    }
    .totalCarPrice{
        height: 30px;
        line-height: 30px;
    }


    /*遮罩*/
    .box{
        display: none;
        position:absolute;
        top:0;
        bottom:0;
        left:0;
        right:0;
        background:#000;
        opacity:0.4;
        width: 100%;
        height: 100%;
        z-index: 11;
        text-align: center;
    }
    .box img{
        width: 90%;
        height: 100%;
    }
    .setReturnJourney{
        font-size: 10px;
        color:#1E9FFF;
    }

    .radius_div{
        display:inline-block;
        float:left;
        font-size:14px;
        margin-top:1px;
        margin-right:5px;
        width: 22px;
        height: 22px;
        border: 1px solid blue;
        border-radius: 22px;
        /*background-color: #0FF;*/
        opacity: 0.5;
    }
</style>
<style>
    .layui-form {
        margin: 15px 0;
    }
    .layui-form-label {
        width: 100px;
        text-align: left;
    }
    .layui-tab {
        border: 1px solid #00F7DE;
    }
    .tab-ul {
        width: 100%;
    }
    .tab-ul li dd {
        /*width: 13.28%;*/
        height: 60px;
        float: left;
        flex: 1;
        /*border: 1px solid #007DDB;*/
    ;
    }
    .tab-ul-title {
        height: 30px;
        /*width: 50%;*/
        text-align: center;
        line-height: 30px;
        font-size: 16px;
        font-weight: bold;
        /*border: 1px solid #007DDB;*/
        border-bottom: 0
    }
    .week-title td {
        text-align: center;
    }
    .layui-table td {
        padding: 0px!important;
    }
    .input_div {
        /*width: 80px;*/
        margin: 5px auto;
    }
    .ri,
    .ri-w {
        padding: 14px 25px;
        background: #eee;
        text-align: center;
    }
    .batch {
        float: right;
        margin-left: 10px;
    }
    .emptys {
        color: #00F7DE;
    }
    #setPriceShade,#setNewPriceShade {
        /*width: 100%;
        height: 100%;*/
        display: none;
    }
    .bj {
        background: #ff7d00 !important;
        color:#fff !important;
    }
    .tas {
        overflow: hidden
    }

    .layui-table tbody tr:hover {
        background-color: ' ' !important;
    }
    .titl{
        padding: 5px 15px;
        width: 100%;
        text-align: center;
        font-size: 16px;
    }
    .light_star{
        background:#fff;
    }
    .new_star{
        background:greenyellow;
    }
    /*.light_star:after{*/
    /*content:'*';*/
    /*width: 0;*/
    /*height: 0;*/
    /*color: red;*/
    /*margin-left: 4px;*/
    /*}*/
    .new_star:after{
        content:'*';
        width: 0;
        height: 0;
        color: deepskyblue;

    }
    .tabto{
        margin-top: 30px;
    }
    .tabto td{
        background: #eee;
    }
    .tabto input{
        border: none;
        background: #eee;
    }
    #specsPriceSnap table tr td input{
        border: none;
    }
    .person_price_input{
        background: #fff !important;
    }
    .personlog{
        height: auto;
        text-align: left;
    }
    .delPersonlog{
        margin-left: 8px;
        margin-right: 16px;
        color:red
    }
    .day_price,.day_price_no{
        text-align: center;
        color: #ff7d00;
        height: 30px;
        line-height: 30px;
        background: #fff;
    }
    .day_price_no{
        background: #eee;
    }
    .specBatchBtn{
        position: absolute;
        right: 70px;
        top: 15px;
    }
    #setNewPriceShade li{
        width:100%;
        float: left;
    }
    .boldsp{
        font-weight: bold;
    }
    .redsp{
        color:red;
    }
    #specs_table{
        border: groove;
    }
    /*#sale_details {*/
        /*height:400px;*/
    /*}*/
    .layui-container {
        width: 100%;
        margin: 0 0 10px 0;
    }
    .box_textarea{
        min-height: 100px;
        max-height: 500px;
    }
    .must_input_star{
        font-size: 16px !important;
        color:red;
        margin-right: 2px;
    }
    .day-description{
        min-height: 100px;
        line-height: 20px;
        padding: 6px 10px;
        resize: none;
        width : 475px;
        margin: 0 0 10px 10px;
        border-radius: 5px;
    }
    .imageVideoBox{
        margin-top:20px;
        margin-bottom:10px;
    }
    .subTitle{
        line-height: 25px;
        height: 60px !important;
        width:70%;
        resize: none;
        padding: 8px;
        overflow: auto !important;
    }
    .changeTextPlan{
        margin-left: 10px;
    }

    .selectedAttr{width:100%}
    .selectedAttr .layui-form-switch{
        margin-left: 40px;
    }
    .layui-icon-ok:before {
        content: "\e605";
    }
    .selectedMasterCustomerInfo,.selectedSecondCustomerInfo{
        margin-left: 180px;
    }
    .selectedAttr .layui-form{margin:0}
    .electronic_addressbox{z-index:161}
</style>
<link rel="stylesheet" href="__PUBLIC__/drag/drag.css"  media="all">
<body>
<div>
    <div class="layui-card">
        <div>
            <form class="layui-form" id="customer" action="">
                <input type="hidden" id="tripid" name="tripid" value="{notempty name='$tripid'}{$tripid}{/notempty}" autocomplete="off">
                <div>
                    <div class="layui-card-header">产品信息</div>
                    <div class="layui-card-body">
                        <ul class="">
                            <div class="layui-container">
                                <div class="layui-row">
                                    <div class="layui-col-md9">
                                        <label class="required_input">产品名称<br>(限63字)：</label>
                                        <input maxlength="63" style="width: 60%;" name="name" id="name" value="{notempty name='$trip.name'}{$trip.name}{/notempty}" lay-verify="required" autocomplete="off" class="layui-input layui-input-inline" type="text">
                                    </div>
                                    <div class="layui-col-md3">
                                        <div class="material_data">
                                            <button class="unifybut" lay-submit lay-filter="customer" style="margin-bottom:0px;">保存</button>
                                            <span style="color:red;">（修改以后请点击保存完成更新）</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-container">
                                <div class="layui-row">
                                    <div class="layui-col-md12">
                                        <label class="required_input"><span class="must_input_star">*</span>{:lang('产品副标题')}({:lang('30字以内')})：</label>
                                        <textarea name="subTitle" lay-verify="required" id="" autocomplete="off" class="layui-input layui-input-inline subTitle" cols="20" rows="10" maxlength="30">{notempty name='$trip.product_sub_title'}{$trip.product_sub_title|default=''}{/notempty}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-container">
                                <div class="layui-row">
                                    <div class="layui-col-md3">
                                        <label>&nbsp;产品编号：</label>
                                        <input name="item_num" id="item_num" value="{notempty name='$trip.item_num'}{$trip.item_num}{/notempty}" lay-verify="required" autocomplete="off" class="layui-input layui-input-inline" type="text" style="width:200px;">
                                    </div>
                                    <div class="layui-col-md3">
                                        <label class="required_input">出发城市：</label>
                                        <div class="layui-input-inline" style="width:200px;margin-left:5px;font-size:12px;">
                                            <select name="start_city" lay-verify="start_city" lay-search>
                                                <option value="" class="custom_input" style="height: 30px;border: 1px solid #ccc">请选择</option>
                                                {volist name="city" id="vo"}
                                                <option class="custom_input" style="height: 30px;border: 1px solid #ccc" value="{$vo.id}" {notempty name='$trip.start_city'}{if $trip.start_city==$vo.id}selected{/if}{/notempty}>{$vo.name}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>

                                </div>
                            </div>
                            {if !$FeaturedProduct}
                            <div class="layui-container">
                                <div class="layui-row">
                                    <div class="layui-col-md3">
                                        <label>&nbsp;出行天数：</label>
                                        <input name="days" id="days" value="{notempty name='$trip.days'}{$trip.days}{/notempty}" autocomplete="off" class="layui-input layui-input-inline" type="text" disabled style="width:200px;">
                                    </div>
                                    <div class="layui-col-md6">
                                        <label class="required_input">服务时长：</label>
                                        <input name="hours" id="hours" value="{notempty name='$trip.hours'}{$trip.hours}{/notempty}" autocomplete="off" placeholder="默认10小时，特殊情况务必写明" class="layui-input layui-input-inline" type="text" style="width:50%;">
                                    </div>

                                </div>
                            </div>
                            {/if}
                            <!--<div class="layui-container">-->
                                <!--<div class="layui-row">-->
                                    <!--<div class="layui-col-md9">-->
                                        <!--<label>&nbsp;平台产品名：</label>-->
                                        <!--<input name="product_name" id="product_name" value="{notempty name='$trip.product_name'}{$trip.product_name}{/notempty}" autocomplete="off" class="layui-input layui-input-inline" type="text" style="width:60%;">-->
                                    <!--</div>-->
                                <!--</div>-->
                            <!--</div>-->
                            <div class="layui-container">
                                <div class="layui-row">
                                    <div class="layui-col-md3">
                                        <label>&nbsp;服务类型：</label>
                                        <div class="layui-input-inline" style="width:200px;margin-left:5px;font-size:12px;">
                                            <select name="service_type" id="service_type" lay-filter="service_type" lay-search="">
                                                <option value="" disabled selected hidden>请选择服务类型</option>
                                                {if !empty($serviceType)}
                                                {volist name="$serviceType" id="vo"}
                                                <option value="{$vo.id}" {if !empty($trip.service_type) && $trip.service_type==$vo.id} selected{/if}>{$vo.name}</option>
                                                {/volist}
                                                {/if}
                                            </select>
                                        </div>
                                    </div>
                                    {if !$FeaturedProduct}
                                    <div class="layui-col-md3">
                                        <label class="required_input">服务语言：</label>
                                        <div class="layui-input-inline" style="width:200px;margin-left:5px;font-size:12px;">
                                            <select name="service_language" id="service_language" lay-filter="service_language" lay-search="">
                                                <option value="0" {if !empty($trip.service_language) && $trip.service_language=='0'} selected{/if}>中文</option>
                                                <option value="1" {if !empty($trip.service_language) && $trip.service_language=='1'} selected{/if}>英文</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-col-md3">
                                        <label>&nbsp;用车类型：</label>
                                        <div class="layui-input-inline" style="width:200px;margin-left:5px;font-size:12px;">
                                            <select name="high_end_vehicle" id="high_end_vehicle" lay-filter="high_end_vehicle" lay-search="">
                                                <option value="0" {if !empty($trip.high_end_vehicle) && $trip.high_end_vehicle=='0'} selected{/if}>普通用车</option>
                                                <option value="1" {if !empty($trip.high_end_vehicle) && $trip.high_end_vehicle=='1'} selected{/if}>高端用车</option>
                                            </select>
                                        </div>
                                    </div>
                                    {/if}
                                </div>
                            </div>
                            <div class="layui-container">
                                <div class="layui-row">
                                    <div class="layui-col-md6">
                                        <label>&nbsp;采购渠道：</label>
                                        <div class="layui-input-inline" style="width:150px;margin-left:5px;font-size:12px;">
                                            <select id="buyType" lay-filter="buyType" lay-search="">
                                                <option value="supplier" {if !empty($trip['supplier_id'])} selected{/if}>供应商</option>
                                                <option value="driver" {if !empty($trip['driver_id'])} selected{/if}>司导</option>
                                            </select>
                                        </div>
                                        <div class="layui-inline driver_div" {if !empty($trip['driver_id'])} selected{/if} style="width:700px;margin-left:5px;font-size:12px;{if empty($trip.driver_id)}display:none;{/if}">
                                            <input type="hidden" id="driver_str" name="driver_str" value="{notempty name="$trip.driver_str"}{$trip.driver_str}{/notempty}">
                                            <select name="driver_id" id="driver_id" lay-filter="driver_id" lay-search="">
                                                {if !empty($trip['driver_id'])}
                                                <option value="{trip.driver_id}">{$trip.driver_str}</option>
                                                {else}
                                                <option value="" disabled selected hidden>请输入司导姓名后回车查询</option>
                                                {/if}
                                            </select>
                                        </div>
                                        <div class="layui-inline supplier_div" style="width:200px;margin-left:5px;font-size:12px;{if !empty($trip.driver_id)}display:none;{/if}">
                                            <select id="supplier_id" lay-search="" disabled>
                                                <option value="" >供应商</option>
                                                <option value="999999" {if  isset($trip['supplier_id']) AND "999999"==$trip['supplier_id']} selected{/if}>自营</option>
                                                {volist name='supplier' id='vo'}
                                                <option value="{$vo.id}" {if  isset($trip['supplier_id']) AND $vo.id==$trip['supplier_id']} selected{/if}>{$vo.name}</option>
                                                {/volist}
                                                <option value="1000000" {if  isset($trip['supplier_id']) AND "1000000"==$trip['supplier_id']} selected{/if}>其他</option>
                                            </select>
                                        </div>
                                        <!--<div class="layui-inline supplier_div" style="font-size:12px;margin-top:3px;margin-left:10px;margin-right:50px;{if !empty($trip.driver_id)}display:none;{/if}">-->
                                            <!--<a href="javascript:void(0);" style="text-decoration:underline;color:blue;" id="toSupplier">查看供应商</a>-->
                                        <!--</div>-->
                                    </div>
                                    <div class="layui-col-md6">
                                        <label>&nbsp;产品编号（供应商）：</label>
                                        <input name="supplier_item_code" id="supplier_item_code" value="{notempty name='$trip.supplier_item_code'}{$trip.supplier_item_code}{/notempty}" autocomplete="off" class="layui-input layui-input-inline supplier_div" type="text" {if !empty($trip.driver_id)}style="display:none;"{else}style="width:200px;"{/if}>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-container">
                                <div class="layui-row">

                                    <div class="layui-col-md4">
                                        <label>&nbsp;展示给tob用户：</label>
                                        <div class="layui-input-inline" style="width:150px;margin-left:10px;margin-top:-5px;font-size:12px;">
                                            <input type="radio" name="tob_pdf" value="1" <?php if(isset($trip['tob_pdf']) && $trip['tob_pdf']=='1'){ echo 'checked';} ?> title="是">
                                            <input type="radio" name="tob_pdf" value="0" <?php if(isset($trip['tob_pdf']) && $trip['tob_pdf']=='0'){ echo 'checked';} ?> title="否">
                                        </div>
                                    </div>
                                    <div class="layui-col-md4">
                                        <label>&nbsp;自动更新价格：</label>
                                        <div class="layui-input-inline" style="width:150px;margin-left:10px;margin-top:-5px;font-size:12px;">
                                            <input type="radio" name="auto_update_price" value="1" <?php if(isset($trip['auto_update_price']) && $trip['auto_update_price']=='1'){ echo 'checked';} ?> title="是">
                                            <input type="radio" name="auto_update_price" value="0" <?php if(isset($trip['auto_update_price']) && $trip['auto_update_price']=='0'){ echo 'checked';} ?> title="否">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-container">
                                <div class="layui-row">
                                    <div class="layui-col-md4">
                                        <label>&nbsp;<span class="must_input_star">*</span>二次确认：</label>
                                        <div class="layui-input-inline" style="margin-left:10px;margin-top:-5px;font-size:12px;">
                                            <!--<input type="radio" name="need_confirm" value="0"  title="未设置" {empty name="$trip.need_confirm"}checked{/empty}>-->
                                            <input type="radio" name="need_confirm" value="1" title="是" {notempty name="$trip.need_confirm"}{if $trip.need_confirm==1}checked{/if}{/notempty}>
                                            <input type="radio" name="need_confirm" value="2" title="否" {notempty name="$trip.need_confirm"}{if $trip.need_confirm==2}checked{/if}{/notempty}>
                                        </div>
                                    </div>
                                    <div class="layui-col-md4">
                                        <label><span class="must_input_star">*</span>{:lang('允许其他分销商采购')}：</label>
                                        <div class="layui-input-inline" style="margin-left:10px;margin-top:-5px;font-size:12px;">
                                            <input type="radio" lay-filter="allow_everyone_quote" name="allow_everyone_quote" value="1" title="{:lang('是')}" {notempty name="$trip.allow_everyone_quote"}{if $trip.allow_everyone_quote==1}checked{/if}{/notempty}>
                                            <input type="radio" lay-filter="allow_everyone_quote" name="allow_everyone_quote" value="0" title="{:lang('否')}" {empty name="$trip.allow_everyone_quote"}checked{/empty}>
                                        </div>
                                    </div>
                                    <div class="layui-col-md4" id="is_group_exhibition_module" {notempty name="$trip.allow_everyone_quote"}style="display:none;"{/notempty}>
                                    <label>{:lang('是否设置为长期展示产品')}：</label>
                                    <div class="layui-input-inline" style="margin-left:10px;margin-top:-5px;font-size:12px;">
                                        <input type="radio" name="is_group_exhibition" value="1" title="{:lang('是')}" {notempty name="$trip.is_group_exhibition"}{if $trip.is_group_exhibition==1}checked{/if}{/notempty}>
                                        <input type="radio" name="is_group_exhibition" value="0" title="{:lang('否')}" {empty name="$trip.is_group_exhibition"}checked{/empty}>
                                    </div>
                                </div>
                                </div>
                            </div>
                            <div class="layui-container">
                                <div class="layui-row">
                                    <div class="layui-col-md12">
                                        <label>&nbsp;标签选择：</label>
                                        <div class="layui-inline" style="width:400px;">
                                            <select id="triptag" lay-filter="addtrips" lay-search>
                                                <option value="">请选择</option>
                                                {volist name="tag" id="vo"}
                                                <option value="{$vo.tag_id}">{$vo.tag_name}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                        <div class="layui-inline">
                                            <span id="addtrips" data-name="" data-id="" class="layui-btn layui-btn-danger layui-btn-sm" style="margin-top:-2px;margin-left:-20px;">添加</span>
                                        </div>
                                        <div class="layui-inline">
                                            <a id="addNewTag" class="layui-btn layui-btn-sm layui-btn-normal">新增</a>
                                            （标签列表中不存在，可点击新增添加）
                                        </div>
                                    </div>
                                    <div class="layui-col-md12">
                                        <label> 已选标签:</label>
                                        <div class="layui-inline" id="tripnames">
                                            {volist name="tagdata" id="vo"}
                                            <span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="{$vo['tag_id']}" style="margin: 5px 10px">{$vo['tag_name']}<i class="layui-icon"></i></span>
                                            {/volist}
                                        </div>
                                        <input name="tag_id" id="tripids" value="{notempty name="$trip.tag_id"}{$trip.tag_id}{/notempty}" type="hidden">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-container">
                                <div class="layui-row">
                                    <div class="layui-col-md12">
                                        <label>&nbsp;产品推荐：</label>
                                        <div class="layui-inline" style="width:400px;">
                                            <select id="allRecommendStandard" lay-filter="allRecommendStandard" lay-search="">
                                                <option value="">请选择</option>
                                                {notempty name="$allRecommendStandard"}
                                                {volist name="allRecommendStandard" id="vo"}
                                                <option value="{$vo.id}">{$vo.name}</option>
                                                {/volist}
                                                {/notempty}
                                            </select>
                                        </div>
                                        <div class="layui-inline">
                                            <span style="color:red;margin-left:20px;">用于分销商商品详情页推荐，仅提供上架且允许分销商采购的产品！</span>
                                        </div>
                                    </div>
                                    <div class="layui-col-md12">
                                        <label> 已选产品:</label>
                                        <div class="layui-inline" id="selectedRecommendStandard">
                                            {notempty name="$selectedRecommendStandard"}
                                            {volist name="selectedRecommendStandard" id="vo"}
                                            <span class="layui-btn layui-btn-sm layui-btn-normal delRecommendStandard" data-id="{$vo['id']}" style="margin: 5px 10px">{$vo['name']}<i class="layui-icon"></i></span>
                                            {/volist}
                                            {/notempty}
                                        </div>
                                        <input name="recommend_standard_ids" id="recommend_standard_ids" value="{notempty name="$trip.recommend_standard_ids"}{$trip.recommend_standard_ids}{/notempty}" type="hidden">
                                    </div>
                                </div>
                            </div>
                        </ul>
                    </div>
                    {if $existGoods}
                    <div class="layui-card-header" style="margin-top:-20px;">{:lang('图片与视频')}</div>
                    <div class="layui-card-body" style="margin-left:-30px;">
                        <div class="imageVideoBox">
                            <div class="layui-row">
                                <form class="layui-form" id="source">
                                    <div class="layui-col-xs6">
                                        <div class="layui-upload">

                                            <button type="button" class="layui-btn" id="upload1">{:lang('轮播主图上传')}（{:lang('格式')}：jpg,png,gif,jpeg）                                                                                      </button>
                                            <span class="must_input_star">*</span>
                                            <span>{:lang('此处图片用于商品展示，请务必上传至少一张')}</span>
                                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                                {:lang('预览')}：
                                                <!--<div id="shared-lists" class="shared-lists">-->
                                                <div class="layui-upload-list example2" id="seeupload1">
                                                    {notempty name='$trip.goodsImages'}
                                                    {volist name="$trip.goodsImages" id="vo"}
                                                    {notempty name='$vo'}
                                                    <span class="uploadimgbox list-group-item"><img class="layui-upload-img" src="{$vo}" width="100px"><i class="layui-icon">&#x1006;</i></span>
                                                    {/notempty}
                                                    {/volist}
                                                    {/notempty}
                                                </div>
                                                <!--</div>-->
                                            </blockquote>
                                        </div>
                                        <input id="upload-thumb1" type="hidden" name="goods_image" value="{notempty name='$goodsData.goods_image'}{$goodsData.goods_image}{/notempty}">
                                    </div>
                                    <div class="layui-col-xs6">
                                        <div class="layui-upload">
                                            <button type="button" class="layui-btn" id="test5"><i class="layui-icon"></i>{:lang('上传视频')}</button>
                                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                                {:lang('预览')}：
                                                <div class="layui-upload-list" id="seevideo">
                                                    {notempty name="$goodsData.goods_video"}
                                                    <video controls style="width:50%">
                                                        <source src="{$goodsData.goods_video}">
                                                    </video>
                                                    <i class="layui-icon deleteVideo" style="vertical-align:top;">&#x1006;</i>
                                                    {/notempty}
                                                </div>
                                            </blockquote>
                                        </div>
                                        <input id="upload-video" type="hidden" name="goods_video" value="{notempty name='$goodsData.goods_video'}{$goodsData.goods_video}{/notempty}">
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <div class="layui-card-header">售卖信息</div>
                    <div class="layui-card-body" style="margin-left:-30px;">
                        <!--<div class="layui-container">-->
                            <!--<div class="layui-row">-->
                                <!--<div class="layui-col-md12">-->
                                    <!--<label>&nbsp;售卖日期：</label>-->
                                    <!--<div class="layui-input-inline" style="width: 200px">-->
                                        <!--<input name="sale_time" id="sale_time" value="{notempty name='$trip.sale_starttime'}{$trip.sale_starttime}{/notempty} - {notempty name='$trip.sale_endtime'}{$trip.sale_endtime}{/notempty}" placeholder=" - " autocomplete="off" class="layui-input"  type="text">-->
                                    <!--</div>-->
                                <!--</div>-->
                            <!--</div>-->
                        <!--</div>-->

                        {if !empty($trip.service_type) && $trip.service_type==14}
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <label>生产日期：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入生产日期" type="text" class="layui-input autoUpdateProductInput" name="production_date" id="production_date" value="{notempty name="$trip.production_date"}{$trip['production_date']}{/notempty}" />
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label>生产许可证号：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入生产许可证号" type="text" class="layui-input autoUpdateProductInput" name="production_license" id="production_license" value="{notempty name="$trip.production_license"}{$trip['production_license']}{/notempty}" />
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label>贮藏条件：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入生产许可证号" type="text" class="layui-input autoUpdateProductInput" name="storage_conditions" id="storage_conditions" value="{notempty name="$trip.storage_conditions"}{$trip['storage_conditions']}{/notempty}" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <label>保质期：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入保质期" class="layui-input autoUpdateProductInput" name="shelf_life" id="shelf_life" value="{notempty name="$trip.shelf_life"}{$trip['shelf_life']}{/notempty}" />
                                    </div>
                                </div>

                                <div class="layui-col-md4">
                                    <label>执行标准号：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入执行标准号" class="layui-input autoUpdateProductInput" name="executive_standard_no" id="executive_standard_no" value="{notempty name="$trip.executive_standard_no"}{$trip['executive_standard_no']}{/notempty}" />
                                    </div>
                                </div>

                                <div class="layui-col-md4">
                                    <label>食用方法：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入执行标准号" class="layui-input autoUpdateProductInput" name="edible_methods" id="edible_methods" value="{notempty name="$trip.edible_methods"}{$trip['edible_methods']}{/notempty}" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <label>净含量：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入净含量" type="text" class="layui-input autoUpdateProductInput" name="net_weight" id="net_weight" value="{notempty name="$trip.net_weight"}{$trip['net_weight']}{/notempty}" />
                                    </div>
                                </div>

                            </div>
                        </div>
                        {elseif !empty($trip.service_type) && $trip.service_type==15}

                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <label>&nbsp;集合地点：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入" class="layui-input autoUpdateProductInput" name="assembling_place" id="assembling_place" value="{notempty name="$trip.assembling_place"}{$trip['assembling_place']}{/notempty}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <label>&nbsp;活动时长：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入" class="layui-input autoUpdateProductInput" name="activity_duration" id="activity_duration" value="{notempty name="$trip.activity_duration"}{$trip['activity_duration']}{/notempty}">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label>&nbsp;活动人数：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入" class="layui-input autoUpdateProductInput" name="activity_person_num" id="activity_person_num" value="{notempty name="$trip.activity_person_num"}{$trip['activity_person_num']}{/notempty}">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label>&nbsp;活动玩法：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入" class="layui-input autoUpdateProductInput" name="play_ways" id="play_ways" value="{notempty name="$trip.play_ways"}{$trip['play_ways']}{/notempty}">
                                    </div>
                                </div>
                            </div>
                        </div>

                        {elseif !empty($trip.service_type) && $trip.service_type==16}
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label>&nbsp;自驾等级：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入" class="layui-input autoUpdateProductInput" name="self_driving_level" id="self_driving_level" value="{notempty name="$trip.self_driving_level"}{$trip['self_driving_level']}{/notempty}">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label>&nbsp;车辆要求：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入" class="layui-input autoUpdateProductInput" name="vehicle_require" id="vehicle_require" value="{notempty name="$trip.vehicle_require"}{$trip['vehicle_require']}{/notempty}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <label>&nbsp;集合地点：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入" class="layui-input autoUpdateProductInput" name="assembling_place" id="assembling_place" value="{notempty name="$trip.assembling_place"}{$trip['assembling_place']}{/notempty}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <label>&nbsp;行程摘要：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入" class="layui-input autoUpdateProductInput" name="itinerary_summary" id="itinerary_summary" value="{notempty name="$trip.itinerary_summary"}{$trip['itinerary_summary']}{/notempty}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <label>&nbsp;自驾路程：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入" class="layui-input autoUpdateProductInput" name="self_driving_distance" id="self_driving_distance" value="{notempty name="$trip.self_driving_distance"}{$trip['self_driving_distance']}{/notempty}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        {elseif !empty($trip.service_type) && $trip.service_type==18}
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label>&nbsp;提供商：</label>
                                    <div class="layui-inline" style="width:60%;">
                                        <select name="electronic_supplier" id="electronic_supplier" class="layui-select">
                                            <option value="">请选择关联提供商</option>
                                            {notempty name="$electronicSupplier"}{volist name="electronicSupplier" id="vo"}
                                            <option value="{$vo.key}" {if !empty($trip.electronic_supplier) && $vo.key==$trip.electronic_supplier}selected{/if}>{$vo.name}</option>
                                            {/volist}{/notempty}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label>&nbsp;旅景通模板ID：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input type="text" name="electronic_tpl_id" autocomplete="off" placeholder="请输入商品对应的tplID" class="layui-input layui-input-inline" value="{$trip.electronic_tpl_id|default=''}" style="width: 250px;">
                                        <a class="layui-btn layui-btn-sm layui-btn-normal verifyTplId">验证模板ID是否有效</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <label>&nbsp;结算价格：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入" class="layui-input" name="electronic_cost_price" id="electronic_cost_price" value="{notempty name="$trip.electronic_cost_price"}{$trip['electronic_cost_price']}{/notempty}">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label>&nbsp;参考价格：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入" class="layui-input" name="electronic_refer_price" id="electronic_refer_price" value="{notempty name="$trip.electronic_refer_price"}{$trip['electronic_refer_price']}{/notempty}">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label>&nbsp;有效期：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入" class="layui-input" name="electronic_validate" id="electronic_validate" value="{notempty name="$trip.electronic_validate"}{$trip['electronic_validate']}{/notempty}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label>&nbsp;关联景区：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入" style="width: 600px;" class="layui-input" name="electronic_scenic_spots" id="electronic_scenic_spots" value="{notempty name="$trip.electronic_scenic_spots"}{$trip['electronic_scenic_spots']}{/notempty}">
                                        <a class="layui-btn-sm layui-btn layui-btn-normal clearMap">清空地图</a>
                                        <div id="electronic_addressbox" class="addressbox"></div>
                                    </div>
                                    <div class="layui-inline" id="electronic_scenic_map" style="width:600px;height:150px;margin-left:80px;">

                                    </div>
                                    <input type="hidden" name="electronic_scenic_latlng" value='{notempty name="$trip.electronic_scenic_latlng"}{$trip["electronic_scenic_latlng"]}{/notempty}'>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label>&nbsp;关联POI：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入" class="layui-input" name="electronic_poi_name" id="electronic_poi_name" value="{notempty name="$trip.electronic_poi_name"}{$trip['electronic_poi_name']}{/notempty}">
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label>&nbsp;作者/来源：</label>
                                    <div class="layui-inline" style="width:50%;">
                                        <input placeholder="请输入" class="layui-input" name="electronic_source" id="electronic_source" value="{notempty name="$trip.electronic_source"}{$trip['electronic_source']}{/notempty}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        {else}

                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label>&nbsp;售卖详情：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <textarea placeholder="请输入售卖日期详情" class="layui-textarea box_textarea autoUpdateProductInput" name="saletime_more" id="saletime_more">{notempty name="$trip.saletime_more"}{$trip['saletime_more']}{/notempty}</textarea>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label>&nbsp;预订流程：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <textarea placeholder="请输入" class="layui-textarea box_textarea autoUpdateProductInput" name="reservation" id="reservation" >{notempty name="$trip.reservation"}{$trip['reservation']}{/notempty}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label>&nbsp;跟团类型：</label>
                                    <div class="layui-inline" style="width: 80%;">
                                        <select name="group_type" id="group_type" lay-filter="group_type" lay-search="">
                                            <option value="1" {if !empty($trip.group_type) && $trip.group_type==1} selected{/if}>请选择跟团类型</option>
                                            <option value="2" {if !empty($trip.group_type) && $trip.group_type==2} selected{/if}>大团跟团</option>
                                            <option value="3" {if !empty($trip.group_type) && $trip.group_type==3} selected{/if}>小团跟团</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label>&nbsp;人数上限：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入人数上限详情" class="layui-input autoUpdateProductInput" name="people_detail" id="people_detail" value="{notempty name="$trip.people_detail"}{$trip['people_detail']}{/notempty}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label>&nbsp;起订人数：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入起订人数" type="number" class="layui-input autoUpdateProductInput" name="start_person_num" id="start_person_num" value="{notempty name="$trip.start_person_num"}{$trip['start_person_num']}{/notempty}" />
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label>&nbsp;成团人数：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <input placeholder="请输入成团人数" class="layui-input autoUpdateProductInput" name="total_person_num" id="total_person_num" value="{notempty name="$trip.total_person_num"}{$trip['total_person_num']}{/notempty}" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <label>&nbsp;内部备注：</label>
                                    <div class="layui-inline" style="width:90%;">
                                        <textarea placeholder="请输入" class="layui-textarea box_textarea autoUpdateProductInput" name="description" id="description" >{notempty name="$trip.description"}{$trip['description']}{/notempty}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {/if}
                    </div>

                    <div class="layui-card-header" style="margin-top:-20px;">价格</div>
                    <div class="layui-card-body" style="margin-left:-30px;">

                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label for="">OTA售价<span style="color:red;">（淡季）</span>:</label>
                                    <div class="layui-inline" style="width:74%;">
                                        <textarea placeholder="请输入OTA价格（淡季）" class="layui-textarea box_textarea autoUpdateProductInput" name="ota_price_out" id="ota_price_out">{notempty name="$trip.ota_price_out"}{$trip['ota_price_out']}{/notempty}</textarea>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label for="">OTA售价<span style="color:red;">（旺季）</span>:</label>
                                    <div class="layui-inline" style="width:74%;">
                                        <textarea placeholder="请输入OTA价格（旺季）" class="layui-textarea box_textarea autoUpdateProductInput" name="ota_price_busy" id="ota_price_busy" >{notempty name="$trip.ota_price_busy"}{$trip['ota_price_busy']}{/notempty}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-card-header" style="margin-top:-20px;">成本</div>
                    <div class="layui-card-body" style="margin-left:-30px;">
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label for="">成本价格<span style="color:red;">（淡季）</span>:</label>
                                    <div class="layui-inline" style="width:74%;">
                                        <textarea placeholder="请输入成本价格（淡季）" class="layui-textarea box_textarea autoUpdateProductInput" name="cost_price_out" id="cost_price_out" >{notempty name="$trip.cost_price_out"}{$trip['cost_price_out']}{/notempty}</textarea>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label for="">成本价格<span style="color:red;">（旺季）</span>:</label>
                                    <div class="layui-inline" style="width:74%;">
                                        <textarea placeholder="请输入成本价格（旺季）" class="layui-textarea box_textarea autoUpdateProductInput" name="cost_price_busy" id="cost_price_busy" >{notempty name="$trip.cost_price_busy"}{$trip['cost_price_busy']}{/notempty}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-card-header" style="margin-top:-20px;">费用说明</div>
                    <div class="layui-card-body" style="margin-left:-30px;">
                        <div class="layui-container">
                            <div class="layui-row">
                                {if !$FeaturedProduct}

                                <div class="layui-col-md6">
                                    <label for="">费用包含：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <textarea placeholder="请输入" class="layui-textarea box_textarea autoUpdateProductInput" name="price" id="price">{notempty name="$trip.price"}{$trip['price']}{/notempty}</textarea>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label for="">费用不含：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <textarea placeholder="请输入" class="layui-textarea box_textarea autoUpdateProductInput" name="priceno" id="priceno">{notempty name="$trip.priceno"}{$trip['priceno']}{/notempty}</textarea>
                                    </div>
                                </div>
                                {else}
                                <div class="layui-col-md6">
                                    <label for="">邮寄说明：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <textarea placeholder="请输入" class="layui-textarea box_textarea autoUpdateProductInput" name="price" id="price">{notempty name="$trip.price"}{$trip['price']}{/notempty}</textarea>
                                    </div>
                                </div>
                                {/if}
                            </div>
                        </div>
                    </div>
                    <div class="layui-card-header" style="margin-top:-20px;">其他</div>
                    <div class="layui-card-body" style="margin-left:-30px;">
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <label for="">特色介绍：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <textarea placeholder="请输入" class="layui-textarea box_textarea autoUpdateProductInput" name="introduction" id="introduction">{notempty name="$trip.introduction"}{$trip['introduction']}{/notempty}</textarea>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label for="">退改规则：</label>
                                    <div class="layui-inline" style="width:80%;">
                                        <textarea placeholder="请输入" class="layui-textarea box_textarea autoUpdateProductInput" name="back" id="back">{notempty name="$trip.back"}{$trip['back']}{/notempty}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <label for="">注意事项：</label>
                                    <div class="layui-inline" style="width:90%;">
                                        <textarea placeholder="请输入" class="layui-textarea box_textarea autoUpdateProductInput" name="careful" id="careful">{notempty name="$trip.careful"}{$trip['careful']}{/notempty}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                    <div class="layui-card-header" style="margin-top:-20px;">更多条款
                        <span style="margin-left: 20px;line-height: 40px;">
                            <a class="layui-btn layui-btn-sm addCustomerContent">新增</a>
                            <!--<a class="layui-btn layui-btn-sm layui-btn-normal saveCustomerContent">保存</a>-->
                        </span>
                    </div>
                    <div class="layui-card-body customerContentDiv" style="margin-left:-30px;">
                        {notempty name="$trip.customer_content"}
                        {if $customer_contents = json_decode($trip.customer_content,true)}
                        {volist name="customer_contents" id="content_value" key="key"}
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <label for=""><input placeholder="请输入标题" class="layui-input layui-input-inline" name="customer_title" value="{$content_value.title}" style="width:20%"><a data-index="{$key}" class="layui-btn layui-btn-sm layui-btn-danger deleteCustomerContent">删除</a></label>
                                    <div class="layui-inline" style="width:100%;">
                                        <textarea placeholder="请输入内容" class="layui-textarea box_textarea" name="customer_content">{$content_value.content}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {/volist}
                        {/if}
                        {/notempty}
                    </div>


                <!-- 出行人信息 -->
                <div class="layui-card-header" style="margin-top:-20px;">{:lang('出行人信息')}</div>
                <div class="layui-card-body" style="margin-left:-20px;margin-bottom:20px;">

                    <div class="layui-form-item">
                        <label class="layui-form-label" style="color:#ff6700;font-size: 13px;width: 150px;">{:lang('出行人填写要求')}</label>
                        <div class="layui-input-block">
                            <input lay-filter="changeAllCustomerReq" type="radio" name="all_customer_req" value="0" title="一个出行人" {if isset($trip.all_customer_req) && $trip.all_customer_req=="0"}checked{/if}>
                            <input lay-filter="changeAllCustomerReq" type="radio" name="all_customer_req" value="1" title="每个出行人" {if isset($trip.all_customer_req) && $trip.all_customer_req=="1"}checked{/if}>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="color:#ff6700;font-size: 13px;width: 150px;">出行人信息</label>
                        <div class="layui-input-block" id="customerAttrs">

                        </div>
                    </div>
                    <div class="layui-form-item" id="masterCustomerInfo">
                        <label class="layui-form-label" style="color:#ff6700;font-size: 13px;width: 150px;">主出行人信息</label>
                        <div class="layui-input-block selectedMasterCustomerInfo">

                        </div>
                    </div>
                    <div class="layui-form-item" id="secondCustomerInfo">
                        <label class="layui-form-label" style="color:#ff6700;font-size: 13px;width: 150px;">次出行人信息</label>
                        <div class="layui-input-block selectedSecondCustomerInfo">

                        </div>
                    </div>
                </div>
                <!-- 出行人信息 -->

                    <div class="layui-card-header" style="margin-top:-20px;">套餐和价格</div>
                    {if !empty($trip.base_price_mode)}
                    <div class="layui-card-body" style="margin-left:-20px;margin-bottom:20px;">
                        <form class="layui-form" action="">
                            <!--<div class="layui-form-item">-->
                                <!--<label for="">帮地接【B端】利润点：</label>-->
                                <!--<div class="layui-inline">-->
                                    <!--<input type="text" class="layui-input layui-input-inline autoUpdateProductInput" name="bdj_rate" placeholder="例：加价10%，请输入0.1" autocomplete="off" value="{notempty name='$trip.bdj_rate'}{$trip.bdj_rate}{/notempty}">-->
                                <!--</div>-->
                            <!--</div>-->
                            <!--<div class="layui-form-item">-->
                                <!--<label for="">快帮行【C端】利润点：</label>-->
                                <!--<div class="layui-inline">-->
                                    <!--<input type="text" class="layui-input layui-input-inline autoUpdateProductInput" name="kbx_rate" placeholder="例：加价10%，请输入0.1" autocomplete="off" value="{notempty name='$trip.kbx_rate'}{$trip.kbx_rate}{/notempty}">-->
                                <!--</div>-->
                            <!--</div>-->
                            <a class="layui-btn layui-btn-sm showProductBasePackage">{:lang('查看')}</a>
                            <a class="layui-btn layui-btn-sm showProductBasePackageRate">{:lang('设置利润')}</a>

                        </form>
                    </div>
                    {else}
                    <div class="layui-card-body" style="margin-left:-20px;margin-bottom:20px;">
                        <a class="layui-btn layui-btn-sm openBasePriceMode">开启基价模式</a>
                    </div>
                    <div class="layui-card-body" style="margin-left:-20px;margin-bottom:20px;">
                        <form class="layui-form">
                            <input type="hidden" id="starttime" value="{notempty name='$trip.sale_starttime'}{$trip.sale_starttime}{/notempty}" placeholder="开始时间" class="layui-input" />
                            <input type="hidden" id="endtime" value="{notempty name='$trip.sale_endtime'}{$trip.sale_endtime}{/notempty}" placeholder="结束时间" class="layui-input" />
                            <input type="hidden" id="product_id" value="{$tripid}" />
                            <ul>
                                <li>
                                    <div class="layui-tab" lay-filter="package" style="margin:0">
                                        <div id="tab-title">
                                            <ul class="layui-tab-title Spec">

                                            </ul>
                                        </div>
                                        <div class="layui-tab-content content" style="overflow: auto;">

                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </form>

                        <!--普通成本弹层-->
                        <div id="setPriceShade">
                            <form class="layui-form" action="" method="post" name="setPriceShade">
                                <input type="hidden" id="specs_ids" value="" />
                                <ul>
                                    <li>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">售卖日期:</label>
                                            <div class="layui-input-inline layui-col-md6">
                                                <input id="normalSalesTime" type="text" value="{notempty name='$trip.sale_starttime'}{$trip.sale_starttime}{/notempty} - {notempty name='$trip.sale_endtime'}{$trip.sale_endtime}{/notempty}" placeholder="开始时间 - 截止时间" class="layui-input" />
                                            </div>
                                        </div>
                                    </li>
                                    <li class="time-content">
                                        <div class="layui-form-item shijian" style="margin: 0;">
                                            <label class="layui-form-label">选择时间段:<br><span style="font-size: 12px;">(时间为当地时间)</span></label>
                                            <div class="layui-input-inline layui-col-md5">
                                                <input type="text" name="t-starttime" value="" autocomplete='off' placeholder="开始时间" class="layui-input x" />
                                            </div>
                                            <div style="text-align: center;line-height: 38px;width: 25px;height: 38px;float: left;margin-right: 10px;">至</div>
                                            <div class="layui-input-inline layui-col-md6">
                                                <input type="text" name="t-endtime" value="" autocomplete='off' placeholder="结束时间" class="layui-input x" />
                                            </div>
                                        </div>
                                    </li>
                                    <li>
                                        <div class="layui-form-item" style="margin: 0;">
                                            <label class="layui-form-label">选择套餐:</label>
                                            <div class="layui-input-inline layui-col-md5">
                                                {volist name='packageList' id='package_v'}
                                                <input type="radio" name="select_package_id" {if $key==0}checked{/if} value="{$package_v['id']}" title="{$package_v['name']}" class="layui-input" lay-filter="change_package" />
                                                {/volist}
                                            </div>

                                        </div>
                                    </li>
                                    <li>
                                        <div class="layui-form-item" style="margin: 0;">
                                            <label class="layui-form-label">&nbsp;</label>
                                            <div class="layui-input-inline layui-col-md12">
                                                在以上时间段中选择：
                                            </div>
                                        </div>
                                    </li>
                                    <li>
                                        <div class="layui-form-item " id="selectTimeForm">


                                        </div>
                                        <div class="layui-form-item " id="moreTimeForm" style="display: none;">
                                            <label class="layui-form-label">&nbsp;</label>
                                            <div class="layui-input-block layui-col-xs8" style="margin: 0;">
                                                <input style="width:160px;" type="text" name="moreTime" autocomplete='off' value="" placeholder="开始时间" class="layui-input layui-input-inline x" />
                                                <a class="layui-btn layui-btn-sm layui-btn-normal addMoreTime">添加</a>
                                            </div>
                                            <div class="layui-input-block layui-col-xs8" style="margin-left:130px;background: #eee;width:620px;">
                                                <div style="width:620px;min-height:50px;" id="moreTimeArr">
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                    <li id="specsPriceSnap">
                                        <div class="layui-input-block layui-col-xs10" style="margin-left:130px;width: 800px;">
                                            <table class="layui-table">
                                                <thead>
                                                <tr>
                                                    <th>名称</th>
                                                    <th>价格</th>
                                                    <th>数量</th>
                                                    <th>最低下单数</th>
                                                    <th>最小增长数</th>
                                                </tr>
                                                </thead>
                                                <tbody class="batch_person">

                                                </tbody>
                                            </table>
                                        </div>
                                    </li>
                                </ul>
                            </form>
                        </div>

                        <!--包车成本弹层-->
                        <div id="setNewPriceShade">
                            <form class="layui-form" action="" method="post" name="setNewPriceShade">
                                <input type="hidden" id="USD_rate" value="" />
                                <input type="hidden" id="CAD_rate" value="" />
                                <input type="hidden" id="JPY_rate" value="" />
                                <input type="hidden" id="vehicle_rate" value="" />
                                <input type="hidden" id="hotel_rate" value="" />
                                <input type="hidden" id="ticket_rate" value="" />
                                <input type="hidden" id="extra_rate" value="" />
                                <input type="hidden" id="new_specs_ids" value="" />
                                <ul>
                                    <li>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">售卖日期:</label>
                                            <div class="layui-input-inline layui-col-md5">
                                                <input id="vehicleSalesTime" type="text" value="{notempty name='$trip.sale_starttime'}{$trip.sale_starttime}{/notempty} - {notempty name='$trip.sale_endtime'}{$trip.sale_endtime}{/notempty}" placeholder="开始时间 - 截止时间" class="layui-input" />
                                            </div>
                                        </div>
                                    </li>
                                    <li class="time-content">
                                        <!--<div class="layui-form-item shijian" style="margin: 0;">-->
                                            <!--<label class="layui-form-label">选择时间段:<br><span style="font-size: 12px;">(时间为当地时间)</span></label>-->
                                            <!--<div class="layui-input-inline layui-col-md5">-->
                                                <!--<input type="text" name="nt-starttime" autocomplete="off" value="" placeholder="开始时间" class="layui-input x" />-->
                                            <!--</div>-->
                                            <!--<div style="text-align: center;line-height: 38px;width: 25px;height: 38px;float: left;margin-right: 10px;">至</div>-->
                                            <!--<div class="layui-input-inline layui-col-md6">-->
                                                <!--<input type="text" name="nt-endtime" autocomplete="off" value="" placeholder="结束时间" class="layui-input x" />-->
                                            <!--</div>-->
                                        <!--</div>-->
                                        <!--库存日期-->
                                        <div class="layui-form-item shijian" id="selectSalesDataArr">
                                            <label class="layui-form-label">库存时间</label>
                                            <div class="layui-input-block layui-col-xs8 noMarginLeft" style="margin: 0;">
                                                <input type="text" name="select_time" autocomplete="off" placeholder="{:lang('选择日期')}" class="layui-input layui-input-inline select_time" />
                                            </div>
                                            <div class="layui-input-block layui-col-xs8" style="background: #eee;width:80%;margin-left:130px;">
                                                <div style="width:100%;min-height:50px;" id="selectTimeArr">
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                    <li>
                                        <div class="layui-form-item" style="margin: 0;">
                                            <label class="layui-form-label">&nbsp;</label>
                                            <div class="layui-input-inline layui-col-md12">
                                                在以上时间段中选择：
                                            </div>
                                        </div>
                                    </li>
                                    <li>
                                        <div class="layui-form-item" id="selectNewTimeForm">

                                        </div>
                                    </li>
                                    <li>
                                        <label class="layui-form-label" style="width:130px;">套餐规格:</label>
                                        <div class="layui-input-inline layui-col-xs10">
                                            <table class="layui-table" id="specs_table" lay-size="sm">
                                                <thead id="specs_head">
                                                <tr>
                                                    <th>车型</th>
                                                    <th>成本</th>
                                                    <th>利率</th>
                                                    <th>售卖价格</th>
                                                </tr>
                                                </thead>
                                                <tbody id="specs_body">

                                                </tbody>
                                            </table>
                                        </div>
                                    </li>
                                    <li>
                                        <label class="layui-form-label" style="width:130px;">用车成本（按车）:</label>
                                        <div class="layui-input-inline layui-col-xs10">
                                            <table class="layui-table" lay-size="sm">
                                                <thead>
                                                <tr>
                                                    <th>车型</th>
                                                    <th>成本（{$currencyName}{$currency}）</th>
                                                    <th>
                                                        <input type="hidden" id="exchangeNum" value="{$exchangeNum}">
                                                        实时汇率
                                                    </th>
                                                    <th>成本（人民币￥）</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <tr>
                                                    <th>5座车</th>
                                                    <th>
                                                        <div style="width:5%;float: left;line-height: 40px;color:red;">{$currency}</div>
                                                        <div style="width:92%;float: left;">
                                                            <input type="number" id="5_cost_currency" class="layui-input" placeholder="请填写{$currencyName}成本" value="{$carPriceArr.f_cost}" />
                                                        </div>
                                                    </th>
                                                    <th>{$exchangeNum}</th>
                                                    <th>
                                                        <div style="width:5%;float: left;line-height: 40px;color:red;">￥</div>
                                                        <div style="width:92%;float: left;">
                                                            <input type="number" id="5_cost" readonly class="layui-input" placeholder="请填写成本" value="" />
                                                        </div>
                                                    </th>
                                                </tr>
                                                <tr>
                                                    <th>7座车</th>
                                                    <th>
                                                        <div style="width:5%;float: left;line-height: 40px;color:red;">{$currency}</div>
                                                        <div style="width:92%;float: left;">
                                                            <input type="number" id="7_cost_currency" class="layui-input" placeholder="请填写{$currencyName}成本" value="{$carPriceArr.s_cost}" />
                                                        </div>
                                                    </th>
                                                    <th>{$exchangeNum}</th>
                                                    <th>
                                                        <div style="width:5%;float: left;line-height: 40px;color:red;">￥</div>
                                                        <div style="width:92%;float: left;">
                                                            <input type="number" id="7_cost" readonly class="layui-input" placeholder="请填写成本" value="" />
                                                        </div>
                                                    </th>
                                                </tr>
                                                <tr>
                                                    <th>12座车</th>
                                                    <th>
                                                        <div style="width:5%;float: left;line-height: 40px;color:red;">{$currency}</div>
                                                        <div style="width:92%;float: left;">
                                                            <input type="number" id="12_cost_currency" class="layui-input" placeholder="请填写{$currencyName}成本" value="{$carPriceArr.t_cost}" />
                                                        </div>
                                                    </th>
                                                    <th>{$exchangeNum}</th>
                                                    <th>
                                                        <div style="width:5%;float: left;line-height: 40px;color:red;">￥</div>
                                                        <div style="width:92%;float: left;">
                                                            <input type="number" id="12_cost" readonly class="layui-input" placeholder="请填写成本" value="" />
                                                        </div>
                                                    </th>
                                                </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </li>
                                    <li>
                                        <label class="layui-form-label" style="width:130px;">额外成本:</label>
                                        <div class="layui-input-inline layui-col-xs10">
                                            <table class="layui-table" lay-size="sm">
                                                <thead>
                                                <tr>
                                                    <th width="10%">司导</th>
                                                    <th width="15%">成本（人民币￥）</th>
                                                    <th width="15%">成本（{$currencyName}{$currency}）</th>
                                                    <th width="50%">成本说明</th>
                                                </tr>
                                                </thead>
                                                <tbody id="extraNode">
                                                {volist name='extra_cost' id='value' key='key'}
                                                <tr>
                                                    <th>
                                                        第{$key}位司导
                                                    </th>
                                                    <th>
                                                        <div style="width:5%;float: left;line-height: 40px;color:red;">￥</div>
                                                        <div style="width:92%;float: left;">
                                                            <input type="number" readonly name="extra_fee_cny" class="layui-input" placeholder="" value="" />
                                                        </div>
                                                    </th>
                                                    <th>
                                                        <div style="width:5%;float: left;line-height: 40px;color:red;">{$currency}</div>
                                                        <div style="width:92%;float: left;">
                                                            <input type="number" readonly name="extra_fee_local" class="layui-input" placeholder="" value="" />
                                                        </div>
                                                    </th>
                                                    <th>
                                                        <div style="width:92%;float: left;">
                                                            <input type="text" readonly name="extra_fee_desc" class="layui-input" placeholder="" value="" />
                                                        </div>
                                                    </th>
                                                </tr>
                                                {/volist}
                                                <tr>
                                                    <th colspan="4">
                                                        <div style="width:92%;float: left;">
                                                            <label for="extra_fee_total">总计(<span style="color:red">￥</span>)</label><input style="width: 50%;margin-left:16px;" type="number" name="extra_fee_total" readonly id="extra_fee_total" class="layui-input layui-input-inline" placeholder="" value="" />
                                                        </div>
                                                    </th>
                                                </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </li>
                                    <li class="more_cost_li" style="display: none;">
                                        <label class="layui-form-label" style="width:130px;">酒店成本（每间）:</label>
                                        <div class="layui-input-inline layui-col-xs10">
                                            <table class="layui-table" lay-size="sm">
                                                <thead>
                                                <tr>
                                                    <th>城市</th>
                                                    <th>星级</th>
                                                    <th>几晚</th>
                                                    <th>成本价格（每间/每晚）</th>
                                                </tr>
                                                </thead>
                                                <tbody id="hotel_body">

                                                </tbody>
                                            </table>
                                        </div>
                                    </li>
                                    <li class="more_cost_li" style="display: none;">
                                        <label class="layui-form-label" style="width:130px;">门票成本（每人）:</label>
                                        <div class="layui-input-inline layui-col-xs10">
                                            <table class="layui-table" lay-size="sm">
                                                <thead>
                                                <tr>
                                                    <th>门票名称</th>
                                                    <th>张数</th>
                                                    <th>成本价格成本价格（每人/每张）</th>
                                                </tr>
                                                </thead>
                                                <tbody id="ticket_body">

                                                </tbody>
                                            </table>
                                        </div>
                                    </li>
                                    <li>
                                        <label class="layui-form-label" style="width:130px;">酒店门票成本启用:</label>
                                        <div class="layui-input-inline" style="margin-top:10px;">
                                            <button data-id="0" id="more_btn" class="layui-btn layui-btn-danger">未启用</button>
                                        </div>
                                    </li>
                                </ul>
                            </form>
                        </div>
                    </div>
                    {/if}

                    {if !$textPlan}
                    <div class="layui-card-header" style="margin-top:-20px;">售卖详情页编辑 <a class="layui-btn layui-btn-sm layui-btn-normal saveSalesDetails">保存详情</a></div>
                    <div class="layui-card-body" style="margin-left:-30px;">
                        <div class="layui-container">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <label for="">详情简介：</label>
                                    <div class="layui-inline" style="width:90%;">
                                        <textarea placeholder="请输入" class="layui-textarea autoUpdateProductInput" name="sale_details" id="sale_details" style="height:400px;">{notempty name="$trip.sale_details"}{$trip['sale_details']}{/notempty}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <div class="layui-container">
                        <div class="layui-row">
                            <div class="layui-col-md12">
                                <label class="layui-form-label"></label>
                                <div class="material_data layui-inline">
                                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="customer" style="margin-bottom:0px;">保存</button>
                                    <span style="color:red;">（修改以后请点击保存完成更新）</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>

        </div>
        <div style="width: 100%;height: 1px;background: #efefef"></div>
        {if !$FeaturedProduct}
        <div class="dragUp"><span>产品信息&nbsp;&nbsp;&nbsp;&nbsp;</span><img src="/icon/up.gif" width=25 height=25 alt=""></div>
        <div class="dragDown"><span>产品信息&nbsp;&nbsp;&nbsp;&nbsp;</span><img src="/icon/down.png" width=25 height=25 alt=""></div>

        <!--行程方案板块-->
        <div class="Travel-plan">
            <div class="layui-card-header">产品方案
                <!--切换节点方案和文本方案-->
                {if $textPlan && $isOpenTextPlan}
                <span style="font-size:12px;color:red;">（{:lang('提示：启用此文本节点方案，售卖详情将以此内容为主！')}）</span>
                <button class="layui-btn layui-btn-sm layui-btn-warm changeTextPlan" data="poi">切换为节点方案</button>
                <a class="layui-btn layui-btn-sm layui-btn-normal saveTextPlan">保存文本方案</a>
                {else}
                <span style="font-size:12px;color:red;">（小技巧：1、POI选择框中输入POI名称，回车查询或创建；  2、节点左侧圆点可拖拽顺序）</span>
                {if $isOpenTextPlan}
                <button class="layui-btn layui-btn-sm layui-btn-warm changeTextPlan" data="text">切换为文本方案</button>
                <button class="layui-btn layui-btn-sm layui-btn-normal createSalesContent">生成售卖详情</button>
                {/if}
                {/if}
            </div>
            {if $textPlan && $isOpenTextPlan}
            <div class="layui-card-body" style="padding: 10px 5px;">
                <textarea placeholder="请输入内容" id="text_plan" class="layui-textarea" name="text_plan" style='height:200px'>{$trip.text_plan|default=''}</textarea>
            </div>
            {else}
            <div class="layui-card-body partitionBox" style="padding: 10px 5px;">
                <!--左中侧数据-->
                <div class="box-left" style="width: 50%;height: 580px;overflow: auto;padding-left: 15px;">
                    <form class="layui-form" id="tripmake">
                        <ul class="layui-timeline" style="height: 100%">
                            {notempty name="$schedule"}
                            {volist name="schedule" id="vo"}
                            <li class="layui-timeline-item addli" id="li_{$vo.id}">
                                <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                                <input type="hidden" class="schedule_id" data-day="{$vo.dayNum}" value="{$vo.id}" autocomplete="off">
                                <div class="layui-timeline-content layui-text">
                                    <h3 class="layui-timeline-title">
                                        <span style="font-size:18px !important;vertical-align:top;">DAY{$vo.dayNum}</span>
                                        <a data-id="{$vo.id}" class="layui-btn-info layui-btn layui-btn-xs getDayMap layui-btn-normal " style="margin-left: 10px;vertical-align:top;margin-top:4px;">显示地图</a>

                                        <!--<div data-id="{$vo.id}" data-type="{$vo.transport_typeids}" class="trafficCar trafficCar_{$vo.id}">-->
                                            <!--<span class="trafficCar_label">请选择交通类型:</span>-->
                                            <!--{volist name='vo.transportList' id='trans_myv'}-->
                                            <!--<p class="layui-btn-info layui-btn layui-btn-xs layui-btn-normal trafficCar_item" data-id="{$trans_myv.id}" >{$trans_myv.title}<i class="layui-icon"></i></p>-->
                                            <!--{/volist}-->
                                        <!--</div>-->
                                    </h3>
                                    <span class="deleteDay "><i class="layui-icon layui-icon-close">&#x1006;</i></span>
                                </div>
                                <div class="layui-form-item" >
                                    <!--<label class="layui-form-label" style="width:130px;">{$vo.time}&nbsp;&nbsp;{$vo.week}</label>-->
                                    <label class="layui-form-label" style="width:50px;">标题</label>
                                    <!--<span class="layui-input-inline changeReplaceDirector">-->
                                        <!--<div class="layui-input-block" style="margin-left:10px;display:inline-block">-->
                                            <!--<input type="checkbox" name="replace_director" data-id="{$vo.id}" lay-filter="changeDirector" lay-skin="switch" <?php if($vo['replace_director']==1){ echo 'checked';} ?> lay-text="更换司导|不换司导">-->
                                        <!--</div>-->
                                    <!--</span>-->
                                    <div class="layui-input-inline" style="width:350px;">
                                        <input type="text" class="layui-input schedule_title" placeholder="请输入标题" value="{notempty name='$vo.title'}{$vo.title}{/notempty}" autocomplete="off">
                                    </div>
                                </div>
                                <div class="layui-timeline-content layui-text">
                                    <textarea data-id="{$vo.id}" class="layui-textarea day-description"  placeholder="请输入当天的简要说明">{notempty name='$vo.day_description'}{$vo.day_description}{/notempty}</textarea>
                                </div>
                                <div class="layui-timeline-content layui-text adddivadd dragsort_div">
                                    <div id="{$vo.id}_did">
                                    {notempty name="$vo.active"}
                                    {volist name="$vo.active" id="active"}
                                        <div class="a_div" id="{$active.id}_aid">
                                            <div class="layui-form-item messdiv" >
                                                <div class="radius_div">
                                                    <div class="keyNumber" style="text-align: center;"></div>
                                                </div>
                                                <input type="hidden" class="active_id" value="{$active.id}" data-day="{$vo.dayNum}" data-sid="{$vo.id}">

                                                <div class="detail-custom-trip detail-custom" style="width:7%;">
                                                    <input type="text" readonly class="layui-input timeInput" value="{notempty name='$active.time'}{$active.time}{/notempty}" style="font-size:12px;">
                                                </div>

                                                <!--添加详细定制下拉信息-->
                                                <!--<label class="layui-form-label">POI</label>-->
                                                <!--详细定制 detail-custom用于来一键切换操作这个class 这个class不用于任何js事件 纯操作class-->
                                                <div class="detail-custom-trip detail-custom">
                                                    <input type="hidden" class="activeType" value="{$active.activeType}" autocomplete="off">
                                                    <div class="detail-create">
                                                        <span>
                                                            {notempty name="$poiClassifyList"}
                                                            {volist name="$poiClassifyList" id="value"}
                                                            {if $active.activeType==$value.id}
                                                            {$value.name}
                                                            {/if}
                                                            {/volist}
                                                            {/notempty}
                                                        </span>
                                                    </div>
                                                    <ul class="detail-create-list">
                                                        {notempty name="$poiClassifyList"}
                                                        {volist name="$poiClassifyList" id="value"}
                                                        <li class="detail-create-list-item" value="{$value.id}">{$value.name}</li>
                                                        {/volist}
                                                        {/notempty}
                                                    </ul>
                                                </div>
                                                <div class="layui-input-inline detail-custom-trip" style="width:15%;">
                                                    <select name="city_{$active.id}" lay-filter="city" lay-search class="city_slt" autocomplete="off" >
                                                        <option value="">城市</option>
                                                        {volist name="city" id="vo1"}
                                                        <option value="{$vo1.id}" {notempty name='$vo1.id'}{if $active.cityid==$vo1.id} selected{/if}{/notempty}>{$vo1.name}</option>
                                                        {/volist}
                                                    </select>
                                                </div>
                                                <div class="layui-input-inline selectpoilist" style="width:45%;">
                                                    {if $active.activeType==6}
                                                    <input data-id="{$active.id}" data-type="6" class="layui-input" type="text" name="other" placeholder="标题" value="{$active.title}" autocomplete="off">
                                                    {else}
                                                    <select data-id="{$active.id}" data-type="{$active.activeType}" name="activeSelect_{$active.id}" lay-filter="activeSelect" lay-search class="activeSelect_slt" id="activeSelect_{$active.id}" data-day="{$vo.dayNum}" data-sid="{$vo.id}">
                                                        <option value="">POI</option>
                                                        {notempty name="$active.poiArr"}
                                                        {volist name="$active.poiArr" id="vo2"}
                                                        <option value="{$vo2.id}" {notempty name='$vo2.id'}{if $active.poiid==$vo2.id} selected{/if}{/notempty}>{$vo2.name}</option>
                                                        {/volist}
                                                        {/notempty}
                                                    </select>
                                                    {/if}
                                                </div>
                                                <div class="layui-timeline-content layui-text">
                                                    <button type="button" class="unifydelbut deletePoi">删除</button>
                                                </div>
                                            </div>
                                            <p class="distance-list">
                                            <span class="distance-list-car">
                                                {if isset($active.limit) && $active.limit>0}
                                                <i class="layui-icon">&#xe715;</i>
                                                相距{$active.limit}公里
                                                {/if}
                                            </span>
                                            </p>
                                        </div>
                                    {/volist}
                                    {/notempty}
                                    </div>
                                    <div class="layui-form-item layui-form-text" style="margin-top:10px;">
                                        <span class="addclassify unifybutadd" data-day="{$vo.dayNum}"> <i class="layui-icon" style="font-size: 30px">&#xe654;</i></span>
                                    </div>
                                </div>
                            </li>
                            {/volist}
                            {/notempty}
                            <!--第二层景点时间轴-->
                            <li class="layui-timeline-item addnumber" style="line-height: 32px;margin-bottom: 50px">
                           <span class="addnumber addnumsty" id="addnumber" style="line-height: 32px">
                                <i class="layui-icon" style="font-size: 30px">&#xe654;</i>
                           </span>
                            </li>
                        </ul>
                    </form>
                </div>
                <!--右侧数据-->
                <div style="width: 50%;height: 580px;overflow: auto; border-left: 1px solid #CCCCCC;padding-left: 10px;z-index: 2" >
                    <div id="poiDataInfo">
                        <div id="show_rightmap" class="border-d2 hidden">
                            <p style="font-weight: bold">
                                展示地图：
                                <span id="totle_duration" style="margin-left:100px;"></span>
                                <span id="totle_total" style="margin-left:100px;"></span>
                                <span style="font-size: 12px;color:#999;"></span>
                                <i class="layui-icon layui-icon-close hideDayMapBtn">ဆ</i>
                            </p>
                            <div id="rightmap"></div>
                        </div>
                        <!--右侧poi详情-->
                        <div id="rightPoiInfo" class="border-d2 hidden" data-id="">
                        </div>
                        <!--右侧门票详情-->
                        <div id="ticketInfo" class="border-d2 hidden" data-id="">
                        </div>
                        <!--右侧修改poi详情-->
                        <div id="updPoiInfo" class="border-d2 hidden">
                            <p style="font-weight: bold" class="item-toggle-p" data-expanded="2">修改信息：<span style="font-size: 12px;color:red;">（请修改信息后点击保存！）</span><span class="item-toggle dragModule">展开</span></p>
                            <form id="updateActiveInfo" style="display:none;">
                                <input type="hidden" name="active_id" value="" autocomplete="off">
                                <div class="rightPoiInfo_item">
                                    <label>活动名称：</label>
                                    <span>
                                    <input name="active_name" readonly value="" placeholder="请输入" autocomplete="off" class="layui-input" type="text" lay-key="3" autocomplete="off">
                                </span>
                                </div>
                                <div class="rightPoiInfo_item" id="updpoi_title">
                                    <label>标题：</label>
                                    <span>
                                    <input name="title" value="" placeholder="请输入" autocomplete="off" class="layui-input" type="text" lay-key="3" autocomplete="off">
                                </span>
                                </div>
                                <div class="rightPoiInfo_item" id="updpoi_flight">
                                    <label>航班信息：</label>
                                    <span>
                                    <input name="flight" value="" placeholder="请输入" class="layui-input" type="text" lay-key="3" autocomplete="off">
                                </span>
                                </div>
                                <!--时间-->
                                <div class="rightPoiInfo_item">
                                    <label>时间：</label>
                                    <span>
                                    <input name="time" id="updpoi_time" value="" placeholder="请输入" autocomplete="off" class="layui-input" type="text" lay-key="3">
                                </span>
                                </div>
                                <!--特别说明-->
                                <div class="rightPoiInfo_item" id="updpoi_content">
                                    <label>备注：</label>
                                    <span style="width:525px;">
                                    <textarea placeholder="请输入内容" id="content" class="layui-textarea" name="content"></textarea>
                                </span>
                                </div>
                                <!--中文简介-->
                                <div class="rightPoiInfo_item" id="updpoi_poicontent">
                                    <label>中文简介：</label>
                                    <span style="width:525px;">
                                    <textarea placeholder="请输入内容" id="poi_content" class="layui-textarea" name="poi_content"></textarea>
                                </span>
                                </div>

                                <!--POI图片-->
                                <div class="rightPoiInfo_item" id="updpoi_img_btn">
                                    <label>图片库：</label>
                                    <span>
                                    <input type="hidden" id="poiImg" name="poiImg" value="" autocomplete="off">
                                    <a href="javascript:void(0);" class="layui-btn layui-btn-sm poiImg_btn" data-poiid="">
                                        打开
                                    </a>
                                </span>
                                </div>
                                <!--其他图片-->
                                <div class="rightPoiInfo_item" id="updother_img_btn">
                                    <label>上传图片：</label>
                                    <span>
                                    <input type="hidden" name="other_images" value="" autocomplete="off">
                                    <button type="button" class="layui-btn layui-btn-sm" id="otherimg_btn">上传</button><input class="layui-upload-file " type="file" name="file" autocomplete="off">
                                </span>
                                </div>
                                <div class="rightPoiInfo_item" id="show_updpoi_img">
                                    <label>预览图：</label>
                                    <span>
                                    <div class="layui-input-inline allImgArr" data-type="">
                                        <span id="poiImgShow"></span>
                                    </div>
                                </span>
                                </div>
                                <div class="rightPoiInfo_item">
                                    <label>自费：</label>
                                    <span>
                                        <input type="checkbox" name="own_fee" title="自费" value="1" style="width:auto;">
                                </span>
                                </div>
                                <div class="rightPoiInfo_item" style="margin-top:10px;">
                                    <label>&nbsp;</label>
                                    <span class="rightPoiInfo_item_span">
                                    <a href="javascript:void(0);" class="rightPoiInfo_item_submit layui-btn updatePoiInfo_btn">
                                        保存
                                    </a>
                                </span>
                                </div>
                            </form>

                        </div>
                        <div id="rightNewPOI" class="border-d2 hidden">
                            <div class="layui-tab layui-tab-card" style="box-shadow: none">
                                <ul class="layui-tab-title">
                                    <li class="layui-this" id="newpoi_typename">景点</li>
                                </ul>
                                <div class="layui-tab-content">
                                    <div id="newpoimap" style="width:600px;height: 150px;margin-bottom:8px;background: #eee;overflow: hidden;margin:8px auto">
                                        <img src="" width="600" height="300" alt="" style="margin-top: -75px">
                                    </div>
                                    <div class="layui-tab-item  layui-show">
                                        <form class="layui-form" id="newpoi" method="post">
                                            <input type="hidden" value="" name="map_thumb_img">
                                            <div class="layui-form-item ourCity">
                                                <label class="layui-form-label">城市</label>
                                                <div class="layui-input-inline" style="position: relative">
                                                    <select name="groupid" lay-search="" autocomplete="off" lay-verify="required">
                                                        <option value="">请选择</option>
                                                        {volist name='ourcity' id='vo'}
                                                        <option value="{$vo.id}">{$vo.name}</option>
                                                        {/volist}
                                                    </select>
                                                </div>
                                            </div>
                                            <input type="hidden" name="typeid" id="newpoi_typeid" value="">

                                            <div class="layui-form-item">
                                                <label class="layui-form-label">名称</label>
                                                <div class="layui-input-inline" style="position: relative">
                                                    <input name="name" maxlength="500" id="poichname" value="" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text">
                                                    <div class="addressbox"></div>

                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">英文名</label>
                                                <div class="layui-input-inline">
                                                    <input name="eng_name" maxlength="500" id="poienname" value=""  placeholder="请输入" autocomplete="off" class="layui-input" type="text">
                                                </div>
                                            </div>

                                            <div class="layui-form-item">
                                                <label class="layui-form-label">地址</label>
                                                <div class="layui-input-inline">
                                                    <input name="address" maxlength="50" id="newpoi_address"  value="{notempty name='$menu'}{$menu.address}{/notempty}" lay-verify="required" readonly placeholder="请根据名称匹配地址,不支持手动输入" autocomplete="off" class="layui-input" type="text">
                                                </div>
                                            </div>
                                            <input type="hidden" id="newpoi_lat" name="lat" value="" autocomplete="off">
                                            <input type="hidden" id="newpoi_lng" name="lng" value="" autocomplete="off">
                                            <input type="hidden" id="newpoi_place_id" name="place_id" value="" autocomplete="off">

                                            <!--中文简介-->
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">中文简介</label>
                                                <div class="layui-input-inline">
                                                    <textarea placeholder="请输入内容" id="newpoi_content" class="layui-textarea" name="introduce"></textarea>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">联系方式</label>
                                                <div class="layui-input-inline">
                                                    <textarea placeholder="请输入内容" class="layui-textarea" name="mobile"></textarea>

                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">来源</label>
                                                <div class="layui-input-inline">
                                                    <input name="source" maxlength="50" value=""  placeholder="请输入" autocomplete="off" class="layui-input" type="text">
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">特别说明</label>
                                                <div class="layui-input-inline">
                                                    <textarea placeholder="请输入内容" class="layui-textarea" name="description"></textarea>
                                                </div>
                                            </div>
                                            <div class="layui-form-item" style="margin:0 110px ">
                                                <div class="layui-upload">
                                                    <button type="button" class="layui-btn" id="upload11">图片上传（格式：jpg,png,gif,jpeg）</button>
                                                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                                        预览图：
                                                        <div class="layui-upload-list" id="seeupload11">
                                                        </div>
                                                    </blockquote>
                                                </div>
                                                <input id="upload-thumb11" type="hidden" name="thumb" value="" autocomplete="off">
                                            </div>
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button type="button" class="layui-btn" lay-submit lay-filter="newpoi">立即提交</button>
                                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                                </div>
                                            </div>

                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="poi-detail poiinfo border-d2 hidden">

                        </div>
                    </div>
                    <style>
                        .transportlist{
                            width:100%;
                        }
                        .transport_item{
                            display: inline-block;
                            width: 45%;
                            margin: 8px;
                            font-size: 24px;
                            text-align: center;
                            border: 1px solid #dfdfdf;
                            line-height:80px ;
                            height: 80px;
                        }
                    </style>
                    <div id="dayDataInfo" hidden>
                        <p style="font-weight: bold" class="">交通类型：<i class="layui-icon layui-icon-close trans_type_close">ဆ</i></p>
                        <div class="transportlist">
                            {volist name='$transport' id='trans_v'}
                            <div class="transport_item" data-type="{$key}">
                                <p>{$trans_v}</p>
                            </div>
                            {/volist}
                        </div>
                    </div>
                </div>
            </div>
            {/if}
        </div>

        <!--右侧按钮-->
        <div class="ActionButton" hidden>
            <!--<div class="Actiondiv ManualSwitch" style="margin-bottom: 10px"><span class="ManualSwitch-span">显示核价</span></div>-->
            <div class="Actiondiv tripimport" style="margin-bottom: 10px" data-id="{$tripid}" >导入行程</div>
            <div class="Actiondiv pronotice" style="margin-bottom: 10px" data-id="{$tripid}" >提醒配置</div>
            <!--<div class="Actiondiv showDayMap {if isset($trip['show_day_map'])&&$trip['show_day_map']=='1'}hidden{/if}" style="margin-bottom: 10px">显示每日地图</div>-->
            <!--<div class="Actiondiv hideDayMap {if isset($trip['show_day_map'])&&$trip['show_day_map']=='0'}hidden{/if}" style="margin-bottom: 10px;background: #FF5722">隐藏每日地图</div>-->
            <!--<div class="Actiondiv showCityMap {if isset($trip['show_city_map'])&&$trip['show_city_map']=='1'}hidden{/if}" style="margin-bottom: 10px">显示城市地图</div>-->
            <!--<div class="Actiondiv hideCityMap {if isset($trip['show_city_map'])&&$trip['show_city_map']=='0'}hidden{/if}" style="margin-bottom: 10px;background: #FF5722">隐藏城市地图</div>-->
            <!--<div class="Actiondiv tripconfig" data-id="{$tripid}" style="margin-bottom: 10px;">产品配置</div>-->
            <!--<div class="Actiondiv updateCityMap" style="margin-bottom: 10px">更新每日地图</div>-->

            <a href="{:url('admin/product/preview',['id'=>$tripid])}" target="_blank" style="color: #fff">
                <div class="Actiondiv previewdiv" style="margin-bottom: 10px"><span>预览</span></div>
            </a>
            <div class="Actiondiv sortdiv" style="margin-bottom: 10px"><span>排序</span></div>
            <div class="Actiondiv saveFile" style="margin-bottom: 10px" data-id="{$tripid}" >上传附件</div>

            <!-- <a href="{:url('admin/product/index')}" style="color: #fff" >
                 <div class="Actiondiv"><span>返回列表</span></div>
             </a>-->
        </div>
        <div class="btnfix">
            <img src="/icon/active_btn.png" alt="">
        </div>
        {/if}
        <!--核价部分-->
        <div style="width: 100%;height: 1px;background: #efefef"></div>
        {if !$FeaturedProduct}
        <div class="dragDownPricing"><span>产品方案&nbsp;&nbsp;&nbsp;&nbsp;</span><img src="/icon/down.png" width=25 height=25 alt=""></div>
        {/if}
        <div class="dragUpPricing"><span>核价信息&nbsp;&nbsp;&nbsp;&nbsp;</span><img src="/icon/up.gif" width=25 height=25 alt=""></div>
        <div class="box-price" id="box-price" hidden>
            <div class="layui-card-header" style="border: none;">核价信息</div>
            <div style="margin-left:5px;margin-bottom:10px;">
                <input id="exportExcel" type="button" value="导出Excel" class="layui-btn" />
            </div>
            <table class="layui-table" style="min-width:170%;max-width:200%;margin-top:-1px;margin-bottom: 150px;" id="summaryPricingTable">
                <thead>
                <tr>
                    <th width="40px" rowspan="2">天数</th>
                    <th width="70px" rowspan="2">标题</th>
                    <th width="70px" rowspan="2">日期</th>
                    <th width="200px" rowspan="2">行程</th>
                    <th width="100px" rowspan="2">航班信息</th>
                    <th width="100px" rowspan="2">航班报价</th>
                    <th width="100px" rowspan="2">酒店信息</th>
                    <th width="100px" rowspan="2">酒店报价</th>
                    <th width="100px" rowspan="2">租车信息</th>
                    <th  style="width: 256px;text-align: center;" colspan="3">用车信息</th>
                    <th width="80px" rowspan="2">门票/活动项目信息</th>
                    <th width="80px" rowspan="2">门票/活动报价</th>
                    <th width="80px" rowspan="2">保险信息</th>
                    <th width="80px" rowspan="2">保险报价</th>
                    <th width="80px" rowspan="2">附加信息</th>
                    <th width="80px" rowspan="2">附加报价</th>
                </tr>
                <tr>
                    <th width="70px" style="text-align: center;">用车类型</th>
                    <th width="70px">总费用</th>
                    <th width="120px">费用说明</th>
                </tr>
                </thead>
                <tbody>
                {notempty name="$priceTable"}
                {volist name="priceTable" id="pric" key='pric_key'}
                <tr data-id="{$pric.id}">
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}">{$pric.day}</td>
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}">{$pric.title}</td>
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}" >{$pric.time}</td>
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}">{$pric.activeText}</td>
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}">
                        {if !empty($pric.airport)}
                        {volist name="$pric.airport" id="airport"}
                        {$airport.typeText}：
                        {$airport.flight}<br style='mso-data-placement:same-cell;'/>
                        {/volist}
                        {/if}
                    </td>
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}">
                        {if !empty($pric.airport)}
                        {volist name="$pric.airport" id="airport"}
                        <div class="airportDiv" style="margin-top:5px;">
                            <textarea data-id="{$airport.id}" placeholder="航班报价明细" name="airportDetail" autocomplete="off" class="layui-textarea table-input-text airportDetail">{notempty name='$airport.detail'}{$airport.detail}{/notempty}</textarea>
                            <span class="money-unit-symbol" style="margin-top:5px;margin-right:8px;">¥</span>
                            <input class="layui-input table-input airportPrice" name="airportPrice" data-id="{$airport.id}" placeholder="价格" autocomplete="off" value="{notempty name='$airport.price'}{$airport.price}{/notempty}" type="number">
                        </div>
                        {/volist}
                        {/if}
                    </td>
                    {if $pric.hotel_id>0}
                    {if $pric.hotel_show > 0}
                    <td rowspan="{$pric['hotel_td_num']}" class="hotel_td table-input" data-num="{$pric.hotel_num}" data-id="{$pric.hotel_id}">{$pric.hotel}</td>
                    <td rowspan="{$pric['hotel_td_num']}">
                        <input type="hidden" class="alldayhotel" value="{$pric.alldayhotel}">
                        <textarea placeholder="酒店明细" name="hotelDetail" class="layui-textarea table-input-text hotelDetail">{notempty name='$pric.tableData.hotelDetail'}{$pric.tableData.hotelDetail}{/notempty}</textarea>
                        <div class="hotel-dealis">
                            <span class="money-unit-symbol" style="margin-right:3px;">¥</span>
                            <input type="number" name="hotelPrice" data-num="{$pric.hotel_num}" class="layui-input inblock hotelPrice" placeholder="单价" autocomplete="off" style="width:50%;" value="{notempty name='$pric.tableData.hotelPrice'}{$pric.tableData.hotelPrice}{/notempty}">
                            *{$pric.hotel_num}天 =<br>
                            <span class="money-unit-symbol" style="margin-top:5px;margin-right:3px;">¥</span>
                            <input type="number" name="totalHotelPrice" class="layui-input inblock totalHotelPrice" placeholder="总价" autocomplete="off" style="width:60%;margin-top:5px;">
                        </div>
                    </td>
                    {/if}
                    {else}
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}"></td>
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}"></td>
                    {/if}


                    {if $pric.drive_num>0}
                    <td rowspan="{$pric.drive_td_num}" data-num="{$pric.drive_num}">
                        <input type="hidden" class="alldaydrive" value="{$pric.alldaydrive}">
                        <textarea placeholder="租车明细" name="driveDetail" class="layui-textarea table-input-text driveDetail">{notempty name='$pric.tableData.driveDetail'}{$pric.tableData.driveDetail}{/notempty}</textarea>
                        <div style="height:5px;"></div>
                        <span class="money-unit-symbol">¥</span>
                        <input type="number" name="drivePrice" data-num="{$pric.drive_num}" class="layui-input inblock drivePrice" placeholder="租车报价" autocomplete="off" style="width:70%;" value="{notempty name='$pric.tableData.drivePrice'}{$pric.tableData.drivePrice}{/notempty}">
                    </td>
                    {else}
                    {if $pric.drive_flag==0}
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}"></td>
                    {/if}
                    {/if}


                    {notempty name='$pric.transport_pricing'}
                    {volist name='$pric.transport_pricing' id='t_value' key='t_key'}
                    {if $t_key<=1}
                    <td>{$t_value.displayString}
                        {if $t_value.displayString=='司导返程'}
                        <span class="deleteReturnJourney" data-day="{$pric.id}"><i class="layui-icon layui-icon-close" style="color:red">ဆ</i></span>
                        {elseif $t_value.serviceType!='Transport_Vehicle_FromAirport' && !$t_value.hasReturn && count($pric['transport_pricing'])==$t_key}
                        <br><br>
                        <a data-day="{$pric.id}" class="setReturnJourney">设置司导返程</a>
                        {/if}</td>
                    <td>
                        <span class="money-unit-symbol">¥</span>
                        <div class="totalCarPrice">
                            {if isset($t_value['totalAmount'])}{$t_value.totalAmount}{/if}
                        </div>
                    </td>
                    <td>
                        {notempty name='$t_value.extra.overtimeFee'}超时费：{$t_value.extra.overtimeFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.hotelFee'}司导酒店费用：{$t_value.extra.hotelFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.dinnerFee'}餐补：{$t_value.extra.dinnerFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.oilFee'}油费：{$t_value.extra.oilFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.parkingFee'}停车费：{$t_value.extra.parkingFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.nightFee'}夜间服务费：{$t_value.extra.nightFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.assistanceFee'}陪护费用，导游费用：{$t_value.extra.assistanceFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.childSeatFee'}儿童座椅：{$t_value.extra.childSeatFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.exceedKMFee'}超出基础里程费用：{$t_value.extra.exceedKMFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.distance'}距离：{$t_value.distance/1000}km<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.duration'}时间：{$t_value.duration/3600|sprintf='%.2f',###}小时<br style='mso-data-placement:same-cell;'/> {/notempty}
                    </td>
                    {/if}
                    {/volist}
                    {/notempty}
                    {empty name='$pric.transport_pricing'}
                    <td></td>
                    <td></td>
                    <td></td>
                    {/empty}
                    <!--门票/活动项目信息-->
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}" class="staff">
                        {empty name='$pric.tableData.ticketDetail'}
                        <div class="staff-not">/</div>
                        <textarea placeholder="门票/活动明细" name="ticketDetail" class="layui-textarea table-input-text staff-have ajaxSubmit ticketDetail"></textarea>
                        {/empty}
                        {notempty name='$pric.tableData.ticketDetail'}
                        <textarea placeholder="门票/活动明细" name="ticketDetail" class="layui-textarea table-input-text ajaxSubmit ticketDetail">{$pric.tableData.ticketDetail}</textarea>
                        {/notempty}
                    </td>
                    <!--门票/活动报价-->
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}" class="staff">
                        {empty name='$pric.tableData.ticketPrice'}
                        <div class="staff-not">/</div>
                        <span class="money-unit-symbol staff-have">¥</span><input type="number" name="ticketPrice" class="layui-input staff-have ajaxSubmit totalTicketPrice" placeholder="门票" autocomplete="off" value="">
                        {/empty}
                        {notempty name='$pric.tableData.ticketPrice'}
                        <span class="money-unit-symbol">¥</span><input type="number" name="ticketPrice" class="layui-input ajaxSubmit totalTicketPrice" placeholder="门票" autocomplete="off" value="{$pric.tableData.ticketPrice}">
                        {/notempty} </td>
                    <!--出境游保险-->
                    {if $pric_key==1}
                    <td rowspan="{$pric.total_td_num}" class="staff">
                        {empty name='$trip.insuranceDetail'}
                        <div class="staff-not">/</div>
                        <textarea placeholder="保险信息" name="insuranceDetail" class="layui-textarea table-input-text staff-have ajaxSubmit insuranceDetail"></textarea>
                        {/empty}
                        {notempty name='$trip.insuranceDetail'}
                        <textarea placeholder="保险信息" name="insuranceDetail" class="layui-textarea table-input-text ajaxSubmit insuranceDetail">{$trip.insuranceDetail}</textarea>
                        {/notempty}
                    </td>
                    <!--保险报价-->
                    <td rowspan="{$pric.total_td_num}" class="staff">
                        {empty name='$trip.insurancePrice'}
                        <div class="staff-not">/</div>
                        <span class="money-unit-symbol staff-have">¥</span>
                        <input type="number" name="insurancePrice" class="layui-input staff-have ajaxSubmit totalInsurancePrice" placeholder="保险报价" autocomplete="off" value="">
                        {/empty}
                        {notempty name='$trip.insurancePrice'}
                        <span class="money-unit-symbol">¥</span>
                        <input type="number" name="insurancePrice" class="layui-input ajaxSubmit totalInsurancePrice" placeholder="保险报价" autocomplete="off" value="{$trip.insurancePrice}">
                        {/notempty}
                    </td>
                    {/if}
                    <!--附加明细-->
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}" class="staff">
                        {empty name='$pric.tableData.extraDetail'}
                        <div class="staff-not">/</div>
                        <textarea placeholder="附加信息" name="extraDetail" class="layui-textarea table-input-text staff-have ajaxSubmit extraDetail"></textarea>
                        {/empty}
                        {notempty name='$pric.tableData.extraDetail'}
                        <textarea placeholder="附加信息" name="extraDetail" class="layui-textarea table-input-text ajaxSubmit extraDetail">{$pric.tableData.extraDetail}</textarea>
                        {/notempty}
                    </td>
                    <!--附加费用-->
                    <td rowspan="{isset($pric['trans_count'])?$pric['trans_count']:1}" class="staff">
                        {empty name='$pric.tableData.extraPrice'}
                        <div class="staff-not">/</div>
                        <span class="money-unit-symbol staff-have">¥</span>
                        <input type="number" name="extraPrice" class="layui-input staff-have ajaxSubmit totalExtraPrice" placeholder="附加费" autocomplete="off" value="">
                        {/empty}
                        {notempty name='$pric.tableData.extraPrice'}
                        <span class="money-unit-symbol">¥</span>
                        <input type="number" name="extraPrice" class="layui-input ajaxSubmit totalExtraPrice" placeholder="附加费" autocomplete="off" value="{$pric.tableData.extraPrice}">
                        {/notempty}
                    </td>
                </tr>
                {notempty name='$pric.transport_pricing'}
                {volist name='$pric.transport_pricing' id='t_value' key='key'}
                {if $key>1}
                <tr>
                    <td>{$t_value.displayString}
                        {if $t_value.displayString=='司导返程'}
                        <span class="deleteReturnJourney" data-day="{$pric.id}"><i class="layui-icon layui-icon-close" style="color:red">ဆ</i></span>
                        {elseif $t_value.serviceType!='Transport_Vehicle_FromAirport' && !$t_value.hasReturn && count($pric['transport_pricing'])==$key}
                        <br><br>
                        <a data-day="{$pric.id}" class="setReturnJourney">设置司导返程</a>
                        {/if}
                    </td>
                    <td>
                        <span class="money-unit-symbol">¥</span>
                        <div class="totalCarPrice">
                            {notempty name='$t_value.totalAmount'}{$t_value.totalAmount}{/notempty}
                        </div>
                    </td>
                    <td>
                        {notempty name='$t_value.extra.overtimeFee'}超时费：{$t_value.extra.overtimeFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.hotelFee'}司导酒店费用：{$t_value.extra.hotelFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.dinnerFee'}餐补：{$t_value.extra.dinnerFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.oilFee'}油费：{$t_value.extra.oilFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.parkingFee'}停车费：{$t_value.extra.parkingFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.nightFee'}夜间服务费：{$t_value.extra.nightFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.assistanceFee'}陪护费用，导游费用：{$t_value.extra.assistanceFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.childSeatFee'}儿童座椅：{$t_value.extra.childSeatFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.extra.exceedKMFee'}超出基础里程费用：{$t_value.extra.exceedKMFee}<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.distance'}距离：{$t_value.distance/1000}km<br style='mso-data-placement:same-cell;'/> {/notempty}
                        {notempty name='$t_value.duration'}时间：{$t_value.duration/3600|sprintf='%.2f',###}小时<br style='mso-data-placement:same-cell;'/> {/notempty}
                    </td>
                </tr>
                {/if}
                {/volist}
                {/notempty}
                {/volist}
                {/notempty}

                <tr style="text-align: center;background-color: #d4d4d4;">
                    <td></td>
                    <td colspan="3">总价</td>
                    <td></td>
                    <td>
                        航班报价
                        <button type="button" value="{$airportPrice_btn}" class="airportPrice_btn layui-btn layui-btn-xs">自填</button>
                    </td>
                    <td></td>
                    <td>
                        酒店报价
                        <button type="button" value="{$hotelPrice_btn}" class="hotelPrice_btn layui-btn layui-btn-xs">自填</button>
                    </td>
                    <td>
                        租车报价
                        <button type="button" value="{$drivePrice_btn}" class="drivePrice_btn layui-btn layui-btn-xs">自填</button>
                    </td>
                    <td></td>
                    <td>
                        用车报价
                        <button type="button" value="{$carPrice_btn}" class="carPrice_btn layui-btn layui-btn-xs">自填</button>
                    </td>
                    <td></td>
                    <td></td>
                    <td>门票/活动报价</td>
                    <td></td>
                    <td>保险报价</td>
                    <td></td>
                    <td>附加费用</td>
                </tr>
                <tr style="text-align: center">
                    <td>/</td>
                    <td colspan="3">
                        <span class="money-unit-symbol-Price">¥</span>
                        <div id="totalPrice" class="symbolPrice"></div>
                    </td>
                    <td>/</td>
                    <td>
                        <div class="airportPrice_ipt">
                            <span class="money-unit-symbol-Price">¥</span>
                            <input class="layui-input" name="airportPrice_ipt" autocomplete="off" value="{if isset($airportPrice_btn) && $airportPrice_btn>0}{$totalAirportPrice}{else}0{/if}" type="number" style="width:73%;display:inline;">
                        </div>
                        <div class="airportPrice_count_ipt">
                            <span class="money-unit-symbol-Price">¥</span>
                            <div id="count_airportPrice" class="symbolPrice">

                            </div>
                        </div>
                    </td>
                    <td>/</td>
                    <td>
                        <div class="hotelPrice_ipt">
                            <span class="money-unit-symbol-Price">¥</span>
                            <input class="layui-input" name="hotelPrice_ipt" autocomplete="off" value="{if isset($hotelPrice_btn) && $hotelPrice_btn>0}{totalHotelPrice}{else}0{/if}" type="number" style="width:73%;display:inline;">
                        </div>
                        <div class="hotelPrice_count_ipt">
                            <span class="money-unit-symbol-Price">¥</span>
                            <div id="count_hotelPrice" class="symbolPrice">

                            </div>
                        </div>
                    </td>
                    <td>
                        <div class="drivePrice_ipt">
                            <span class="money-unit-symbol-Price">¥</span>
                            <input class="layui-input" name="drivePrice_ipt" autocomplete="off" value="{if isset($drivePrice_btn) && $drivePrice_btn>0}{$totalDrivePrice}{else}0{/if}" type="number" style="width:73%;display:inline;">
                        </div>
                        <div class="drivePrice_count_ipt">
                            <span class="money-unit-symbol-Price">¥</span>
                            <div id="count_drivePrice" class="symbolPrice">

                            </div>
                        </div>
                    </td>
                    <td>/</td>
                    <td>
                        <div class="carPrice_ipt">
                            <span class="money-unit-symbol-Price">¥</span>
                            <input class="layui-input" name="carPrice_ipt" autocomplete="off" value="{if isset($carPrice_btn) && $carPrice_btn>0}{$totalTransPrice}{else}0{/if}" type="number" style="width:73%;display:inline;">
                        </div>
                        <div class="carPrice_count_ipt">
                            <span class="money-unit-symbol-Price">¥</span>
                            <div id="count_carPrice" class="symbolPrice">

                            </div>
                        </div>
                    </td>
                    <td>/</td>
                    <td>/</td>
                    <td>
                        <span class="money-unit-symbol-Price">¥</span>
                        <div id="count_ticketPrice" class="symbolPrice">

                        </div>
                    </td>
                    <td>/</td>
                    <td>
                        <span class="money-unit-symbol-Price">¥</span>
                        <div id="count_insurancePrice" class="symbolPrice">

                        </div>
                    </td>
                    <td>/</td>
                    <td>
                        <span class="money-unit-symbol-Price">¥</span>
                        <div id="count_extraPrice" class="symbolPrice">

                        </div>
                    </td>
                </tr>

                </tbody>
            </table>
        </div>
    </div>
    <!--遮罩-->
    <div class="box">
        <img src="/icon/shade-page.png" alt="">
    </div>
</div>

<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script src="__PUBLIC__/jquery/jquery.table2excel.js"></script>
<script src="__PUBLIC__/jquery/table2excel.min.js"></script>
<script>
    var currencyCodeList = {$currencyCodeList};
    var exchangeList = {$exchangeList};
    var product_currency = "{$product_currency}";
    var poiClassifyList = {$poiClassifyList|json_encode};
    var global_active_type_arr = {$global_active_type_arr};
    var  is_show_shadow= {if isset($trip.is_show_shadow)}{$trip.is_show_shadow}{else}0{/if};
    //上边表单部分
    sessionStorage.setItem("expanded",'2');
    if(sessionStorage.getItem("isClose")=='true'){
        $("#customer").hide();
        $(".dragUp").hide();
        $(".dragDown").show();
    }else{
        $("#customer").show();
        $(".dragUp").show();
        $(".dragDown").hide();
    }
    //下边核价部分
    if(sessionStorage.getItem("isClosePricing")=='false' ||sessionStorage.getItem("isClosePricing")==undefined){
        $(".box-price").hide();  //核价板块
        $('.Travel-plan').show() //行程方案 板块
        $(".dragUpPricing").hide();
        $(".dragDownPricing").hide();
        // window.location.reload()
        $('.box-price').remove("switcherset"); //删除

    }else{
        $(".box-price").show(); //核价板块
        $('.Travel-plan').hide() //行程方案 板块
        $(".dragUpPricing").hide();
        $(".dragDownPricing").show();
        $('.box-price').addClass("switcherset"); //添加
    }

    //所有得input显示 为无 显示为 /

    $('.staff').click(function () {
        if($(this).children().eq(0).hasClass('staff-not')){
            $(this).children().eq(0).hide()
            $(this).children().eq(1).show()
            $(this).children().eq(2).show()
        }
    });

    /*自动撑开textarea*/
    function readyNumber() {
        $('textarea').not("[name=sale_details]").each(function () {
            this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');
        }).on('input', function () {
            this.style.height = 'auto';
            this.style.height = (this.scrollHeight) + 'px';
        })
    }

    readyNumber();
</script>
<script src="{$Think.config.amap_url}"></script>
<script>
    //当前地图是否可见
    var visibleMap = false;
    var showAutoUpdateMsg = false;
    layui.use(['layer', 'laydate', 'form'], function() {
        var layer = layui.layer,
            $ = layui.jquery,
            form = layui.form;
        var laydate = layui.laydate;
        laydate.render({     //创建时间选择框
            elem: '#sale_time' //指定元素
            ,range:true
            ,format: 'yyyy-MM-dd'
            ,done:function(value,date){
                var product_id = $("#tripid").val();
                if(product_id=='' || product_id==undefined){
                    return false;
                }
                var sale_time = value.split(' - ');
                var param = {};
                param.id = product_id;
                param.sale_starttime = sale_time[0] || '';
                param.sale_endtime = sale_time[1] || '';
                autoUpdateProductInfo(param);
            }
        });
        laydate.render({     //创建时间选择框
            elem: '#vehicleSalesTime' //指定元素
            ,range:true
            ,done:function(value,date){
                var product_id = $("#tripid").val();
                if(product_id=='' || product_id==undefined){
                    return false;
                }
                var sale_time = value.split(' - ');
                var param = {};
                param.id = product_id;
                param.sale_starttime = sale_time[0] || '';
                param.sale_endtime = sale_time[1] || '';
                autoUpdateProductInfo(param);
                renderSelectTime(param.sale_starttime,param.sale_endtime)
            }
        });
        laydate.render({     //创建时间选择框
            elem: '#normalSalesTime' //指定元素
            ,range:true
            ,done:function(value,date){
                var product_id = $("#tripid").val();
                if(product_id=='' || product_id==undefined){
                    return false;
                }
                var sale_time = value.split(' - ');
                var param = {};
                param.id = product_id;
                param.sale_starttime = sale_time[0] || '';
                param.sale_endtime = sale_time[1] || '';
                autoUpdateProductInfo(param);
            }
        });
        /将后台时间戳数据转为标准时间/
        function formatTime(date) {
            /* 从Date对象（标准时间格式）返回对应数据 */
            var dateObj = {};
            var date = new Date(date);
            dateObj.year = date.getFullYear();
            dateObj.month = date.getMonth();//关键
            dateObj.date = date.getDate();
            dateObj.hours = date.getHours();
            dateObj.minutes = date.getMinutes();
            dateObj.seconds = date.getSeconds();
            return dateObj;
        }
        function renderSelectTime(startDate,endDate){
            if(selectTimeLayDate!==null){
                var startDateObj = formatTime(startDate);
                var endDateObj = formatTime(endDate);
                console.log(startDateObj,endDateObj)

                selectTimeLayDate.config.min = startDateObj;
                selectTimeLayDate.config.max = endDateObj;
                return false;
            }
            selectTimeLayDate = laydate.render({     //创建时间选择框
                elem: '.select_time' //指定元素
                ,range:true
                ,min:startDate
                ,max:endDate
                ,trigger:'click'
                ,done: function(value, date){
                    var sale_time = value.split(' - ');
                    if(sale_time.length < 2){layer.msg('{:lang("请正确设置选择日期")}');return false;}
                    addNewSelectTime(value);
                    return false;
                }
            });

        }
        {if !empty($trip.sale_starttime) && !empty($trip.sale_endtime)}
        var init_startDate = "{$trip.sale_starttime}";
        var init_endDate = "{$trip.sale_endtime}";
        var selectTimeLayDate = null;
        renderSelectTime(init_startDate,init_endDate);
        {/if}
        function addNewSelectTime(time_str){
            if(time_str=="" || time_str==undefined){
                layer.msg("请选择日期");return false;
            }
            var selectTimeList = [];
            var str = '';
            var selectTimeArr = $("#selectTimeArr a");
            selectTimeArr.each(function (i,v) {
                selectTimeList.push($(v).attr('data-id'));
            })
            if(selectTimeList.length < 1){
                //直接插入
                str = '<a class="layui-btn layui-btn-sm layui-bg-cyan deleteSelectTime" data-id="'+time_str+'" style="margin:8px;">'+time_str+' <i class="layui-icon">&#x1006;</i></a>\n';
            }else{
                //判断是否存在
                if($.inArray(time_str,selectTimeList)>-1){
                    //存在 跳过
                    layer.msg("请勿重复添加日期");return false;
                }else{
                    //不存在 插入
                    str = '<a class="layui-btn layui-btn-sm layui-bg-cyan deleteSelectTime" data-id="'+time_str+'" style="margin:8px;">'+time_str+' <i class="layui-icon">&#x1006;</i></a>\n';
                }
            }
            if(str==""){
                layer.msg("请选择日期");return false;
            }
            $("#selectTimeArr").append(str);
        }
        $(document).on('click','.deleteSelectTime',function(){
            $(this).remove();
        })
        //删除具体的天数
        $(document).on('click','.delMoreTime',function(){
            $(this).remove();
        });
        var laydate1 = layui.laydate;
        laydate1.render({     //创建时间选择框
            elem: '#sale_starttime' //指定元素
            ,format: 'yyyy-MM-dd'
        });
        var laydate2 = layui.laydate;
        laydate2.render({     //创建时间选择框
            elem: '#sale_endtime' //指定元素
            ,format: 'yyyy-MM-dd'
        });

        $('.autoUpdateProductInput').blur(function(){
            var product_id = $("#tripid").val();
            var value = $(this).val();
            var param = {};
            var key = $(this).attr('name');
            param[key] = value;
            param.id = product_id;
            autoUpdateProductInfo(param);
        })
        form.on('select(group_type)',function(data){
            var product_id = $("#tripid").val();
            var value = data.value;
            var param = {};
            param.group_type = value;
            param.id = product_id;
            autoUpdateProductInfo(param);
        })
        //更换司导
        //切换禁用启用
        form.on('switch(changeDirector)', function(data){
            var id= $(this).attr('data-id');
            var value;

            if(data.elem.checked){
                value =1;
            }else{
                value =0;
            }
            $.ajax({
                url:"{:url('admin/product/changeDirector')}",
                data:{'id':id,'value':value},
                type:'post',
                async: false,
                success:function(res) {
                    layer.msg(res.msg);
                }
            })
        });

        $('.poiImg_btn').click(function(){
            var id = $(this).attr('data-poiid');
            var url="/admin/trip/addpoiimg/id/"+id+".shtml";
            layer.open({
                type:2,
                content:url,
                area: ['50%', '90%'],
                end:function(){
                    return false;
                }
            });

            return false;
        });
        $('.tripconfig').click(function(){
            var url = "/admin/product/productconfig";
            var id = $(this).attr("data-id");
            layer.open({
                'type':2,
                'content':url+"?id="+id,
                'area':['50%','90%'],
                'end':function(){

                }
            })
        });

        //导入行程
        $('.tripimport').click(function(){
            var url = "/admin/product/productimport";
            var id = $(this).attr("data-id");
            layer.open({
                'type':2,
                'content':url+"?id="+id,
                'area':['50%','90%'],
                'end':function(){
                    window.location.reload();
                }
            })
        });
        //增加提醒消息
        $('.pronotice').click(function(){
            var url = "/admin/product/pronotice";
            var id = $(this).attr("data-id");
            layer.open({
                'type':2,
                'content':url+"?id="+id,
                'area':['80%','95%'],
                'end':function(){
                    //window.location.reload();
                }
            })
        });
        //上传附件
        $('.saveFile').click(function(){
            var url = "/admin/product/product_attachment";
            var id = $(this).attr("data-id");
            layer.open({
                'type':2,
                'content':url+"?id="+id,
                'area':['80%','90%'],
                'end':function(){
                    window.location.reload();
                }
            })
        });

        //弹窗的点击事件
        var i=$('#tripid').attr('value');
        if(i<=0){
            var url = "info";
            layer.open({
                type: 2,
                content: url,
                area: ['900px', '600px'],
                end: function () {
                    var tripid= $('#tripid').attr("value")
                    if(tripid>0){
                        location.href="/admin/product/productmake?id="+tripid;
                    }else{
                        location.href="{:url('admin/product/index')}";
                    }
                }
            });
        }

        //打开每日地图 右侧展示
        function rendderEveryMap(map){
            //关闭详情
            //$("#rightPoiInfo").hide();
            //$("#ticketInfo").hide();
            initMap("rightmap",map.start_poi,map.end_poi,map.middle_poi);
            if(!checkMapResult("rightmap")){
                $("#show_rightmap").show();
                layer.msg("规划路线失败");
            }else{
                visibleMap = true;
            }
        }

        $(".getDayMap").click(function(){
            var id = $(this).attr('data-id');
            getEveryDayMapPoint(id);
        });

        $(".hideDayMapBtn").click(function(){
            visibleMap = false;
            hideRightMap()
        });

        function getEveryDayMapPoint(id){
            $.get("/admin/product/getDayMap?ajax=1&id="+id,{},function(data){
                if(data.code==200){
                    $("#show_rightmap").show();
                    var hasLine = data.data.hasLine;
                    var mappoints = data.data.map;
                    if(hasLine){
                        rendderEveryMap(mappoints)
                    }else{
                        notGetMapInfo()
                    }
                }
            },"json")
        }

        function notGetMapInfo(){
            hideRightMap();
            $("#rightmap").children().remove();
            layer.msg('路线规划失败');
        }

        function hideRightMap(){
            //关闭详情
            $("#show_rightmap").hide();
        }

        //新增POI
        $('body').on('click','.addclassify',function () {
            var schedule_id = $(this).parent().parent().parent().find(".schedule_id").attr("value");
            var active_id = 0;
            var addbtn = $(this);
            var a_div = addbtn.parent().parent().find(".a_div:last");
            var precityid = a_div.find(".city_slt").val();
            var anchor = addbtn.parent().parent().parent().attr("id");
            var activeType = a_div.find(".activeType").attr("value");

            sessionStorage.setItem("tripmake_anchor",anchor);
            $.ajax({
                url:"{:url('addActive')}",
                type:'post',
                data:{schedule_id:schedule_id,cityid:precityid,activeType:activeType},
                success:function(res) {
                    if(res.code==1){
                        active_id = res.data;
                        var html = a_div.find(".messdiv").html();
                        //添加poi的距离
                        var p_html = a_div.find(".distance-list").html();
                        var p_html = "<p class='distance-list'>"+p_html+"</p>";

                        if(html=='' || html==null){
                            location.reload();
                            return false;
                        }

                        html = "<div class='a_div' id='"+active_id+"_aid'><div class='layui-form-item messdiv'><div id='addActive_flag_"+active_id+"'></div>"+html;
                        html = html  + '</div>' + p_html;
                        addbtn.parent().prev().append(html);
                        addbtn.parent().prev().find("#"+active_id+"_aid .active_id").val(active_id);
                        if(activeType==6){
                            addbtn.parent().prev().find("#"+active_id+"_aid .selectpoilist input[name=other]").attr('data-id',active_id);
                        }

                        $("#addActive_flag_"+active_id).next(".active_id").attr("value",active_id);
                        $("#addActive_flag_"+active_id).parent().find(".city_slt").attr("name","city_"+active_id);
                        $("#addActive_flag_"+active_id).parent().find(".city_slt").find('option:selected').removeAttr("selected");
                        $("#addActive_flag_"+active_id).parent().find(".city_slt").val(precityid);
                        $("#addActive_flag_"+active_id).parent().find(".activeSelect_slt").attr("name","activeSelect_"+active_id);
                        $("#addActive_flag_"+active_id).parent().find(".activeSelect_slt").attr("id","activeSelect_"+active_id);
                        $("#addActive_flag_"+active_id).parent().find(".activeSelect_slt").attr("data-id",active_id);
                        $("#addActive_flag_"+active_id).parent().find(".activeSelect_slt").find('option:selected').removeAttr("selected");
                        $("#addActive_flag_"+active_id).remove();
                        form.render('select');
                        console.log(precityid);

                        poiInvertSelect();

                        //重置节点前后距离
                        getPointDistace(active_id,schedule_id);

                        allSortKeyNum();
                    }else{
                        layer.msg(res.msg);
                        return false;
                    }
                }
            });
        });

        //新增天数
        $('#addnumber').bind('click',function () {
            var tripid=$('#tripid').attr("value");
            var that=$(this);
            $.ajax({
                url:"{:url('addDay')}",
                type:'post',
                data:{tripid:tripid},
                success:function(res) {
                    if(res.code==1){
                        var anchor = $(that).parent().prev().find(".schedule_id").val();
                        sessionStorage.setItem("tripmake_anchor","li_"+anchor);
                        location.reload();
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });

        //选择城市
        form.on('select(city)', function(param){
            var city_id = param.value;
            if(city_id=="" || city_id==undefined){
                return false;
            }
            var select = $(this).parent().parent().parent().find(".city_slt");
            var name = select.attr("name");
            var numArr = name.split("_");
            var active_id = numArr[1];
            var type_id = select.parent().parent().find(".activeType").attr("value");

            setActiveSelect(type_id,city_id,active_id);

            //重置节点前后距离
            var schedule_id = select.parent().parent().parent().parent().find(".schedule_id").attr("value");
            getPointDistace(active_id,schedule_id);
        });

        function getActiveTypeName(type_id)
        {
            var typename="";
            type_id = parseInt(type_id);
            $.each(poiClassifyList,function(i,v){
                if(type_id==v.id){
                    typename = v.name;
                    return false;
                }
            })

            return typename;
        }
        //渲染activeSelect选择框
        function setActiveSelect(type_id,city_id,active_id){
            var typename = '';
            switch(type_id){
                case 1://POI
                    typename = '请选择POI';
                    break;
                case 2://接机
                    typename = '请选择机场';
                    break;
                case 3://送机
                    typename = '请选择机场';
                    break;
                case 4://酒店
                    typename = '请选择酒店';
                    break;
                case 5://特色体验
                    typename = '特色体验';
                    break;
                case 6://其他
                    typename = '其他';
                    break;
            }
            var html = '';
            if(city_id>0){
                $.ajax({
                    url:"{:url('admin/product/getActiveData')}",
                    data:{type_id:type_id,active_id:active_id,city_id:city_id},
                    type:'post',
                    async: false,
                    success:function(data) {
                        html += "<option value=''>"+typename+"</option>";
                        for(var i=0;i<data.length;i++){
                            html += "<option value="+data[i]["id"]+">"+data[i]["name"]+"</option>";
                        }
                    }
                });
            }

            $("#activeSelect_"+active_id).html(html);
            //重新渲染select
            form.render('select');
            poiInvertSelect();
        }

        //选中active
        form.on('select(activeSelect)', function(param){
            var item_id = param.value;
            if( item_id=="" || item_id==undefined ){
                return false;
            }

            var item_text = $(this).text();
            var active_id = $(this).parent().parent().parent().parent().find(".active_id").attr("value");
            var citySelect = $(this).parent().parent().parent().parent().find(".city_slt");
            var type_id = citySelect.parent().parent().find(".activeType").attr("value");//类型id
            var dayNum = $(this).parent().parent().prev().attr("data-day");
            var schedule_id = $(this).parent().parent().prev().attr("data-sid");
            var city_id = citySelect.val();
            var groupid = 0;
            var typeid = 0;

            $.ajax({
                url:"{:url('admin/product/setActive')}",
                data:{active_id:active_id,item_id:item_id,type_id:type_id,item_text:item_text},
                type:'post',
                async: false,
                success:function(res) {
                    groupid = res.data.groupid;
                    typeid = res.data.typeid;
                }
            });

            //重置节点前后距离
            getPointDistace(active_id,schedule_id);

            //更新侧边栏
            getRecommendList(item_id,dayNum,schedule_id,type_id,active_id,item_text);

            if(groupid!=='' && parseInt(groupid)!==parseInt(city_id)){
                citySelect.val(groupid);
                $.post("{:url('admin/product/getpoiByInput')}",{city_id:groupid},function(data){
                    var html="<option value=''>POI</option>";
                    for(var i=0;i<data.length;i++){
                        html += "<option value="+data[i]["id"]+">"+data[i]["name"]+"</option>";
                    }

                    $("#activeSelect_"+active_id).html(html);
                    $("#activeSelect_"+active_id).val(item_id);

                    //重新渲染select
                    form.render('select');

                    poiInvertSelect();
                },"Json");
            }

            //重新获取节点的分类
            console.log(typeid,type_id,getActiveTypeName(typeid));
            if(typeid!=='' && parseInt(typeid)!==parseInt(type_id)){
                citySelect.parent().parent().find(".activeType").attr("value",typeid);
                citySelect.parent().parent().find(".activeType").next().children().text(getActiveTypeName(typeid));
            }
        });

        //填写title
        $('body').on('blur','.schedule_title',function (){
            var title = $(this).val();
            var schedule_id = $(this).parent().parent().parent().find(".schedule_id").attr("value");
            if(title==''){
                return false;
            }
            $.post("{:url('admin/product/changeTitle')}",{title:title,schedule_id:schedule_id},function(res){
                if(res.code==1){

                }else{
                    //layer.msg(res.msg);
                }
            },"Json");
            return false;
        });
        //保存输入的简要说明
        $(".day-description").blur(function(){
            var schedule_id = $(this).attr('data-id');
            var value = $(this).val();
            $.post("{:url('admin/product/saveDayDescription')}",{schedule_id:schedule_id,value:value},function(res){
                if(res.code<1){
                    layer.msg(res.msg);
                }
            },'json')
        })
        //开启基价模式
        $(".openBasePriceMode").click(function(){
            var tripid=$('#tripid').attr('value');
            layer.confirm("确认开启基价模式吗？已设置价格将会废弃，需要重新设置套餐和价格！",function(){
                var loading = layer.load(2, {
                    shade: false
                });
                $.post("{:url('admin/product/openBasePriceMode')}",{id:tripid},function(res){
                    layer.close(loading);
                    layer.msg(res.msg);
                    if(res.code>0){
                        setTimeout(function(){
                            window.location.reload();
                        },1000)
                    }
                },'json')
            })
        })
        //删除节点
        $('body').on('click','.deletePoi',function () {
            var active_id = $(this).parent().parent().find(".active_id").attr("value");
            var schedule_id = $(this).parent().parent().parent().parent().parent().parent().find(".schedule_id").attr("value");
            var that = $(this);

            var prev_activeId = $(this).parent().parent().parent().prev().prev(".a_div").find(".active_id").attr("value");
            var next_activeId = $(this).parent().parent().parent().next().next(".a_div").find(".active_id").attr("value");

            layer.confirm('确定要删除吗?', function() {
                var loading = layer.load(2, {
                    shade: false
                });

                $.ajax({
                    url:"{:url('deletePoi')}",
                    type:'post',
                    data:{active_id:active_id},
                    success:function(res) {
                        layer.close(loading);
                        if(res.code==1){
                            layer.msg(res.msg);
                            that.parent().parent().parent().remove();
                            resetRightModuleData();
                            //重置节点前后距离
                            if(prev_activeId!==null && prev_activeId>0){
                                getPointDistace(prev_activeId,schedule_id);
                            }else{
                                if(next_activeId!==null && next_activeId>0){
                                    getPointDistace(next_activeId,schedule_id);
                                }
                            }

                            allSortKeyNum();

                            if(visibleMap){
                                //重新渲染地图
                                getEveryDayMapPoint(schedule_id);
                                return false;
                            }
                        }else{
                            layer.msg(res.msg);
                            return false;
                        }
                    }
                });
            });
            return false;
        });
        function resetRightModuleData(){
            $("#updPoiInfo").hide();
            $("#rightPoiInfo").hide();
            $("#ticketInfo").hide();
            $("#rightNewPOI").hide();
            $(".poiinfo").hide();
        }
        //删除Day
        $('body').on('click','.deleteDay',function () {
            var schedule_id = $(this).parent().parent().find(".schedule_id").attr("value");
            var that = this;
            layer.confirm('确定要删除吗?', function() {
                var loading = layer.load(2, {
                    shade: false
                });
                $.ajax({
                    url:"{:url('deleteDay')}",
                    type:'post',
                    data:{schedule_id:schedule_id},
                    success:function(res) {
                        layer.close(loading);
                        if(res.code==1){
                            layer.msg(res.msg);
                            var anchor = $(that).parent().parent().prev().find(".schedule_id").val();
                            console.log()
                            sessionStorage.setItem("tripmake_anchor","li_"+anchor);
                            location.reload();
                            return false;
                        }else{
                            layer.msg(res.msg);
                            return false;
                        }
                    }
                });
            });

            return false;
        });

        //点击打开排序sortdiv
        $('.sortdiv').click(function () {
            var url = "/admin/product/dragsort";
            var tripid=$('#tripid').attr('value');
            layer.open({
                title:'排序',
                type: 2,
                content: url+'?id='+tripid,
                area: ['96%', '90%'],
                end: function () {
                    location.reload();
                }
            });
            return false;
        });

        //更新行程城市地图
        $(".updateCityMap").click(function(){
            var tripid = $("input[name=tripid]").val();
            if(tripid=="" || tripid==undefined){
                layer.msg("请先添加行程信息");
                return false;
            }
            var update_city_map = layer.load(1);
            $.post("/admin/product/updateEveryDayPOIMapImg",{'trip_id':tripid},function(data){
                layer.close(update_city_map);
                layer.msg(data.msg);
            },"json")
        });

        //显示每日地图
        $(".showDayMap").click(function(){
            changeDayMapShow(1);
        });

        //隐藏每日地图
        $(".hideDayMap").click(function(){
            changeDayMapShow(0)
        });

        //显示城市地图
        $(".showCityMap").click(function(){
            changeCityMapShow(1);
        });

        //隐藏每日地图
        $(".hideCityMap").click(function(){
            changeCityMapShow(0)
        });

        //更新信息
        form.on('submit(customer)', function(data) {
            var name=$('#name').val();
            var item_num=$('#item_num').val();
            if(name !=='' && item_num !==''){
                $.ajax({
                    url:"{:url('/admin/product/changeInfo')}",
                    data:$('#customer').serialize(),
                    type:'post',
                    async: false,
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code > 0){
                            location.reload();
                            return false;
                        }
                    }
                })
            }else{
                layer.msg('关键信息不能为空！')
            }
            return false;
        });

        function changeDayMapShow(show){
            var tripid = $("input[name=tripid]").val();
            if(tripid=="" || tripid==undefined){
                layer.msg("请先添加行程信息");
                return false;
            }
            var day_map_show = layer.load(1);
            $.post("/admin/product/changeShowScheduleMapImg",{'trip_id':tripid,'is_show':show},function(data){
                layer.close(day_map_show);
                if(data.code==200){
                    if(show==0){
                        $(".showDayMap").show();
                        $(".hideDayMap").hide();
                        layer.msg("已隐藏每日地图");
                    }else{
                        $(".showDayMap").hide();
                        $(".hideDayMap").show();
                        layer.msg("已显示每日地图");
                    }
                }else{
                    layer.msg(data.msg);
                }
            },"json")
        }

        function changeCityMapShow(show){
            var tripid = $("input[name=tripid]").val();
            if(tripid=="" || tripid==undefined){
                layer.msg("请先添加行程信息");
                return false;
            }
            var day_map_show = layer.load(1);
            $.post("/admin/product/changeShowCityMapImg",{'trip_id':tripid,'is_show':show},function(data){
                layer.close(day_map_show);
                if(data.code==200){
                    if(show==0){
                        $(".showCityMap").show();
                        $(".hideCityMap").hide();
                        layer.msg("已隐藏城市地图");
                    }else{
                        $(".showCityMap").hide();
                        $(".hideCityMap").show();
                        layer.msg("已显示城市地图");
                    }
                }else{
                    layer.msg(data.msg);
                }
            },"json")
        }

        //获取推荐列表案例
        $('body').on('click',".selectpoilist input",selectPoi3);

        function selectPoi3(e) {
            changRightShowDataType();
            //添加颜色  $('.messdiv')
            var shadow= $(this);
            $('.activeinput').removeClass("activeinput");
            $(shadow).addClass("activeinput");
            hideRightMap();
            var input = $(this).val();
            if(input=="" || input==undefined){
                return false;
            }
            var type_id = $(this).attr("data-type");
            var dayNum = schedule_id = input_poIid = active_id = 0;
            if(type_id=='6'){
                var hidden_active= $(this).parent().parent();
                dayNum = hidden_active.find(".active_id").attr('data-day')
                schedule_id = hidden_active.find(".active_id").attr('data-sid')
                active_id = hidden_active.find(".active_id").attr('value');
                //赋值setTitle
                $.post("/admin/product/updateActiveInfo",{active_id:active_id,title:input, activeType: 6},function(res){},'json')
                //隐藏poi详情 地图
                $("#rightPoiInfo").hide();
                $("#ticketInfo").hide();
                $("#show_rightmap").hide();
            }else{
                //取消名字不显示
                // shadow.val('');
                shadow.select();
                var select_poi = $(this).parent().parent();
                input_poIid= select_poi.prev().find('option:selected').val()
                dayNum = select_poi.parent().find("select").attr('data-day')
                schedule_id= select_poi.parent().find("select").attr('data-sid')
                active_id = select_poi.parent().parent().find(".active_id").val();
                type_id = $(this).parent().parent().parent().parent().find(".activeType").attr("value");
                //显示poi详情 地图
                console.log('show');
                $("#rightPoiInfo").show();
                $("#ticketInfo").show();
                if(visibleMap){
                    $("#show_rightmap").show();
                }
            }
            getRecommendList(input_poIid,dayNum,schedule_id,type_id,active_id,input)

        }

        //渲染右侧数据
        function renderRightPoiData(data,dayNum,schedule_id,active_type_id,self){
            //开始渲染
            var htmldiv='';
            $('.poi-detail').children().remove();
            htmldiv+='<p style="font-weight: bold" class="item-toggle-p" data-expanded="3">附近POI：<span style="font-size: 12px;color:#999;">(tips:点击左侧poi,然后点击小图执行添加,附近POI会添加到当天行程的最后)</span><span class="item-toggle dragModule">收起</span></p>\n'
            htmldiv+='<div class="nearbyPoiList">';
            htmldiv+='<div id="nearbyPoiMap"></div>\n';
            for(var i=0;i<data.length;i++){
                htmldiv+='  <div class="poi-detail-item" data-cid="'+data[i].cityId+'" data-pid="'+data[i].id+'" data-day="'+dayNum+'" data-sid="'+schedule_id+'" data-tid="'+active_type_id+'">\n' +
                    '                        <div class="poi-detail-item-imgbox">\n' ;
                if(+data[i].name.length>8){
                    htmldiv+='<p class="poi-detail-item-title1">'+data[i].name+'</p>\n';
                }else{
                    htmldiv+='<p class="poi-detail-item-title">'+data[i].name+'</p>\n';
                }

                htmldiv+= '</div>\n' +
                    '                        <div class="poi-p-list-box">\n' +
                    '                        <p>'+data[i].eng_name+'</p>\n' +
                    '                        <p>'+data[i].distance+'km</p>\n' +
                    '                        </div>\n'+
                    '                    </div>'
            }
            htmldiv+='</div>';
            $('.poi-detail').append(htmldiv);
            if(sessionStorage.getItem("expanded")=='3'){
                $(".nearbyPoiList").slideDown(250);
                $(".nearbyPoiList").prev().find(".dragModule").html("收起");
            }else{
                $(".nearbyPoiList").slideUp(250);
                $(".nearbyPoiList").prev().find(".dragModule").html("展开");
            }

            //渲染附近景点地图
            if(data.length>0 && self!==null){
                map_name = "nearbyPoiMap";
                var selfPoi = {};
                selfPoi.lat = parseFloat(self.lat);
                selfPoi.lng = parseFloat(self.lng);
                initMapPoint(map_name,selfPoi,data,selfPoi)
            }

            //如果地图显示状态刷新地图
            if(visibleMap){
                //模拟点击显示地图
                $("#li_"+schedule_id).find(".getDayMap").click();
            }
        }

        function getRecommendList(poiid,dayNum,schedule_id,active_type_id,active_id,active_name){
            //开启更新信息
            showUpdPoiInfo(active_id,active_type_id,active_name);
            if($.inArray(parseInt(active_type_id),global_active_type_arr)>-1){
                //poi与酒店
                //获取poi详情
                var self = getPOIInfo(poiid,active_id);
                $(".poiinfo").show();
                if(active_type_id==1){
                    $.post("/admin/product/getRecommendPoiList",{poi_id:poiid},function(data){
                        renderRightPoiData(data.data,dayNum,schedule_id,active_type_id,self)
                    },'json');
                    //获取上一次得点击值
                    console.log(sessionStorage.getItem('expanded'));
                    if(sessionStorage.getItem('expanded')=='2'){
                        $("#updateActiveInfo").slideDown(250);
                        $("#updateActiveInfo").prev().find(".dragModule").html("收起");
                    }else{
                        $("#updateActiveInfo").slideUp(250);
                        $("#updateActiveInfo").prev().find(".dragModule").html("展开");
                    }
                }else{
                    $(".poiinfo").hide();
                }
            }else{
                $("#rightPoiInfo").hide();
                $("#ticketInfo").hide();
                $(".poiinfo").hide();
                $("#updateActiveInfo").slideDown(250);
                $("#updateActiveInfo").prev().find(".dragModule").html("收起");
            }
        }
        function showUpdPoiInfo(active_id,active_type_id,active_name)
        {
            $("#updPoiInfo").show();
            resetUpdPoiInfo();
            //获取新的active数据
            $.post("/admin/product/getActiveInfo",{active_id:active_id},function(res){
                if(res.code==200) {
                    var typename = getActiveTypeName(parseInt(active_type_id));
                    $("#updateActiveInfo input[name=active_name]").val(typename+"---"+active_name);
                    if ($.inArray(parseInt(active_type_id),global_active_type_arr) > -1) {
                        $("#updother_img_btn").hide();
                        $("#updpoi_img_btn").show();
                        $("#show_updpoi_img").show();
                        $("#updpoi_title").hide();
                        $("#updpoi_poicontent").show();
                        $("#updpoi_flight").hide();
                    } else if($.inArray(active_type_id, ['6']) > -1){
                        $("#updpoi_img_btn").hide();
                        $("#updother_img_btn").show();
                        $("#updpoi_title").show();
                        $("#updpoi_poicontent").hide();
                        $("#show_updpoi_img").show();
                        $("#updpoi_flight").hide();
                    }else if($.inArray(active_type_id, ['2','3']) > -1){
                        $("#updpoi_poicontent").hide();
                        $("#updpoi_img_btn").hide();
                        $("#updother_img_btn").hide();
                        $("#updpoi_title").hide();
                        $("#show_updpoi_img").hide();
                        //显示航班信息
                        $("#updpoi_flight").show();
                    }else{
                        $("#updpoi_poicontent").hide();
                        $("#updpoi_img_btn").hide();
                        $("#updother_img_btn").hide();
                        $("#updpoi_title").hide();
                        $("#show_updpoi_img").hide();
                        $("#updpoi_flight").hide();
                    }
                    var data = res.data;
                    $(".poiImg_btn").attr("data-poiid",data.poiid);
                    $("#updateActiveInfo input[name=active_id]").val(data.id);
                    $("#updateActiveInfo input[name=title]").val(data.title);
                    if(data.time==0){
                        data.time = '';
                    }
                    $("#updateActiveInfo input[name=time]").val(data.time);

                    // $("#updateActiveInfo textarea[name=content]").val(data.content);
                    if(data.content!==null){
                    ue1.setContent(data.content);
                    }
                    //机场的详情不赋值
                    if(data.poi_content!==null && $.inArray(parseInt(active_type_id), global_active_type_arr) > -1){
                        ue.setContent(data.poi_content);
                    }
                    $("#updateActiveInfo .allImgArr").attr('data-type',active_type_id);
                    $("#updateActiveInfo input[name=flight]").val(data.flight);
                    $("#updateActiveInfo input[name=poiImg]").val(data.poiImg);
                    $("#updateActiveInfo input[name=other_images]").val(data.other_images);
                    if(data.own_fee==1){
                        $("#updateActiveInfo input[name=own_fee]").prop('checked',true);
                    }else{
                        $("#updateActiveInfo input[name=own_fee]").removeAttr('checked');
                    }
                    var imghtml = "";
                    if (data.poiImg_arr.length > 0 && $.inArray(parseInt(active_type_id),global_active_type_arr) > -1) {
                        $.each(data.poiImg_arr, function (i, v) {
                            imghtml += '<div style="display:inline-block">' +
                                '<img class="layui-upload-img" src="' + v + '" style="width:85px;padding:5px;">' +
                                '<i class="layui-icon">&#x1006;</i>' +
                                '</div>';
                        });
                        $("#poiImgShow").children().remove();
                        $("#poiImgShow").append(imghtml);
                    }
                    if (data.other_images_arr.length > 0 && $.inArray(active_type_id, ['6']) > -1) {
                        $.each(data.other_images_arr, function (i, v) {
                            imghtml += '<div style="display:inline-block">' +
                                '<img class="layui-upload-img" src="' + v + '" style="width:85px;padding:5px;">' +
                                '<i class="layui-icon">&#x1006;</i>' +
                                '</div>';
                        })
                        $("#poiImgShow").children().remove();
                        $("#poiImgShow").append(imghtml);
                    }

                }else{
                    layer.msg(res.msg);
                }
            },'json')
        }

        function resetUpdPoiInfo()
        {
            $("#updateActiveInfo input[name=active_id]").val(0);
            $("#updateActiveInfo input[name=active_name]").val("");
            $("#updateActiveInfo input[name=title]").val("");
            $("#updateActiveInfo input[name=time]").val("");
            $("#updateActiveInfo input[name=own_fee]").removeAttr("checked");
            $("#updateActiveInfo textarea[name=content]").val("");
            $("#updateActiveInfo textarea[name=poi_content]").val("");
            $("#updateActiveInfo input[name=poiImg]").val("");
            $("#updateActiveInfo input[name=other_images]").val("");
            $("#updateActiveInfo input[name=flight]").val("");
            //富文本编辑器赋空
            ue.setContent("");
            ue1.setContent("");
            $("#poiImgShow").children().remove();
        }

        function getPOIInfo(poiid,active_id){
            $("#rightPoiInfo").show();
            $("#ticketInfo").show();
            var self = null;
            $.ajax({
                url:"/admin/poi/getPOIInfo",
                type:"POST",
                data:{id:poiid,active_id:active_id,table:'pactive'},
                dataType:"json",
                async:false,
                success:function(data) {
                    self = data.data;
                    //POI详情
                    $("#rightPoiInfo").children().remove();
                    var html="";
                    html+='<p style="font-weight: bold" class="item-toggle-p" data-expanded="1">POI详情：<span style="font-size: 12px;color:#999;">&nbsp;</span><span class="item-toggle dragModule">展开</span></p>\n'
                    html+='<div style="display:none;" id="poiinfoitem">';
                    $.each(data.data,function(i,v){
                        var showKey = ['address','description','mobile','open_time','source'];
                        var showKeyName = ['地址','简介','联系方式','时间','来源'];
                        //中文名称
                        if(i=='name'){
                            html += '<p id="poi_name">'+v+'</p>';
                            //英文名
                        }else if(i=='eng_name'){
                            html += '<p id="poi_engname">'+v+'</p>';
                            //详情
                        }else if(i=='introduce' && $.trim(v)!="" && v!=null){
                            html += '<div class="rightPoiInfo_item">\n' +
                                '<label>详情：</label>\n' +
                                '<span><div id="poi_introduce">'+v+'</div></span>\n' +
                                '</div>';
                            //其他
                        }else if($.inArray(i,showKey)!=-1 && $.trim(v)!="" && v!=null){
                            var showname = showKeyName[$.inArray(i,showKey)];
                            html += '<div class="rightPoiInfo_item">\n' +
                                '<label>'+showname+'：</label>\n' +
                                '<span>'+v+'</span>\n' +
                                '</div>';
                        }
                    });
                    html+='</div>';
                    $("#rightPoiInfo").append(html)

                    $("#ticketInfo").hide();
                    $("#ticketInfo").children().remove();
                    if(data.activeType==1){
                        $("#ticketInfo").show();
                        //门票
                        var thtml="";
                        thtml+='<p style="font-weight: bold" class="item-toggle-p" data-expanded="1">门票详情：<span style="font-size: 12px;color:#999;">&nbsp;</span><span class="item-toggle dragModule">展开</span></p>\n'
                        thtml+='<div style="display:none;" id="ticketinfoitem">';
                        if(data.ticket_status==0){
                            thtml+='<button type="button" class="layui-btn layui-btn-danger layui-btn-sm ticketBtn" data-value="'+data.ticket_status+'" style="margin-left:10px;">未启用</button>';
                        }else{
                            thtml+='<button type="button" class="layui-btn layui-btn-sm ticketBtn" data-value="'+data.ticket_status+'" style="margin-left:10px;">启用中</button>';
                        }

                        $.each(data.data,function(i,v){
                            var showKey = ['ticket','ticket_cost','ticket_last_admin','ticket_last_updtime'];
                            var showKeyName = ['门票描述','门票成本','更新人','更新时间'];
                            if($.inArray(i,showKey)!=-1 && $.trim(v)!="" && v!=null){
                                var showname = showKeyName[$.inArray(i,showKey)];
                                thtml += '<div class="ticketInfo_item">\n' +
                                    '<label>'+showname+'：</label>\n' +
                                    '<span>'+v+'</span>\n' +
                                    '</div>';
                            }
                        });

                        if(data.ticket.length>0){
                            thtml += '<table class="layui-table" lay-even="" lay-skin="row" lay-size="sm">' +
                                '<colgroup>' +
                                '<col width="50%">' +
                                '<col width="10%">' +
                                '<col width="20%">' +
                                '<col width="20%">' +
                                '</colgroup>' +
                                '<thead>' +
                                '<tr>' +
                                '<th>门票名称</th>' +
                                '<th>数量</th>' +
                                '<th style="text-align: center;">建议销售价</th>' +
                                '<th style="text-align: center;">采购成本价</th>' +
                                '</tr>' +
                                '</thead>' +
                                '<tbody id="ticket_body">';

                            $.each(data.ticket,function(i,v){
                                var currency = "美元$";
                                $.each(currencyCodeList,function(curr_i,curr_v){
                                    if(v.currency==curr_v.currency_code){
                                        currency = curr_v.currency_name+curr_v.currency_symbol;
                                        return false;
                                    }
                                })

                                var sale_price = '';
                                if(v.sale_price!=='' && v.sale_price!==undefined && v.sale_price>=0){
                                    sale_price = currency+' '+v.sale_price;
                                }
                                var cost_price = '';
                                if(v.cost_price!=='' && v.cost_price!==undefined && v.cost_price>=0){
                                    cost_price = currency+' '+v.cost_price;
                                }

                                thtml += '<tr class="ticket_tr">' +
                                    '<td><span>'+v.name+'</span></td>' +
                                    '<td><span>x 1</span></td>' +
                                    '<td style="text-align: center;">' +
                                    '<span>'+sale_price+'</span>' +
                                    '</td>' +
                                    '<td style="text-align: center;">' +
                                    '<span>'+cost_price+'</span>' +
                                    '</td>' +
                                    '</tr>';
                            });
                        }

                        thtml+='</div>';
                        $("#ticketInfo").append(thtml);
                    }

                    if(sessionStorage.getItem('expanded')=='1'){
                        $("#poiinfoitem").slideDown(250);
                        $("#poiinfoitem").prev().find(".dragModule").html("收起");
                    }else{
                        $("#poiinfoitem").slideUp(250);
                        $("#poiinfoitem").prev().find(".dragModule").html("展开");
                    }
                }
            })
            return self;
        }
        //从推荐poi加入行程
        $('body').on('click','.poi-detail-item',function () {
            var export_flag_index = layer.load(2);
            var _that = this;
            $(_that).addClass("disabled");
            var dayNum = $(this).attr("data-day");
            var cid = $(this).attr("data-cid");
            var pid = $(this).attr("data-pid");
            var tid = $(this).attr("data-tid");
            var schedule_id=$(this).attr("data-sid");
            //增加一行POI
            var addbtn =$(".addclassify[data-day='"+dayNum+"']");
            $.ajax({
                url:"{:url('addActive')}",
                type:'post',
                data:{schedule_id:schedule_id,cityid:cid},
                success:function(res) {
                    if(res.code==1){
                        var active_id = res.data;
                        var a_div = addbtn.parent().parent().find(".a_div:last");
                        var left_last_type_id = a_div.find(".activeType").attr("value");
                        var html = a_div.find(".messdiv").html();
                        //添加poi的距离
                        var p_html = a_div.find(".distance-list").html();
                        p_html = "<p class='distance-list'>"+p_html+"</p>";

                        if(html=='' || html==null){
                            location.reload();
                            return false;
                        }

                        html = "<div class='a_div' id='"+active_id+"_aid'><div class='layui-form-item messdiv'><div id='addActive_flag_"+active_id+"'></div>"+html;
                        html = html  + '</div>' + p_html;
                        addbtn.parent().prev().append(html);
                        addbtn.parent().prev().find("#"+active_id+"_aid .active_id").val(active_id);

                        $("#addActive_flag_"+active_id).next(".active_id").attr("value",active_id);
                        $("#addActive_flag_"+active_id).parent().find(".city_slt").attr("name","city_"+active_id);
                        $("#addActive_flag_"+active_id).parent().find(".city_slt").find('option:selected').removeAttr("selected");
                        $("#addActive_flag_"+active_id).parent().find(".city_slt").val(cid);
                        $("#addActive_flag_"+active_id).parent().find(".activeSelect_slt").attr("name","activeSelect_"+active_id);
                        $("#addActive_flag_"+active_id).parent().find(".activeSelect_slt").attr("id","activeSelect_"+active_id);
                        $("#addActive_flag_"+active_id).parent().find(".activeSelect_slt").find('option:selected').removeAttr("selected");
                        $("#addActive_flag_"+active_id).remove();
                        form.render('select');
                        //render poilist
                        $.post("{:url('admin/product/getActiveData')}",{active_id:active_id,city_id:cid,type_id:tid},function(data){
                            var html="<option value=''>POI</option>";
                            for(var i=0;i<data.length;i++){
                                html += "<option value="+data[i]["id"]+">"+data[i]["name"]+"</option>";
                            }
                            if(left_last_type_id=='6'){
                                addbtn.parent().prev().prev().find(".selectpoilist").children().remove();
                                var select_html = '<select data-id="'+active_id+'" data-type="'+tid+'" name="activeSelect_'+active_id+'" lay-filter="activeSelect" lay-search class="activeSelect_slt" id="activeSelect_'+active_id+'" data-day="'+dayNum+'" data-sid="'+schedule_id+'"></select>';
                                addbtn.parent().prev().prev().find(".selectpoilist").append(select_html);
                            }
                            //重新渲染左侧类型和poi的select框
                            addbtn.parent().prev().prev().find(".activeType").attr("value",tid);
                            var typename = getActiveTypeName(parseInt(tid));
                            console.log(typename);
                            addbtn.parent().prev().prev().find(".detail-create span").html(typename);

                            $("#activeSelect_"+active_id).html(html);
                            $("#activeSelect_"+active_id).val(pid)
                            //重新渲染select
                            form.render('select');
                            //setpoi 推荐poi时保存导入的poi数据
                            $.ajax({
                                url:"{:url('admin/product/setpoi')}",
                                data:{active_id:active_id,poiid:pid},
                                type:'post',
                                async: false,
                                success:function(res) {
                                    groupid = res.data.groupid;
                                    if(visibleMap){
                                        //重新渲染地图
                                        getEveryDayMapPoint(schedule_id);
                                    }
                                    //重置节点前后距离
                                    getPointDistace(active_id,schedule_id);
                                }
                            });
                            poiInvertSelect();
                        },"Json");
                        setTimeout(function(){
                            layer.msg('添加成功',{time:500});
                            layer.close(export_flag_index);
                        },500);
                        $(_that).removeClass("disabled");

                        allSortKeyNum();
                    }else{
                        layer.msg(res.msg);
                        return false;
                    }
                }
            });
        });
        //点击地图上的点 从推荐poi加入行程
        $('body').on('click','.mapPoi',function(){
            var poiid = $(this).attr('data-id');
            console.log(poiid);
            $(".poi-detail-item[data-pid="+poiid+"]").click();
        })
        $('input[name=own_fee]').click(function(){
            var value = $(this).is(":checked");
            var id = $(this).parent().parent().parent().find('input[name=active_id]').val();
            var own_fee = 0;
            if(value){
                own_fee = 1;
            }
            $.post("/admin/product/setProductActiveOwnFee",{id:id,own_fee:own_fee},function(data){
            },'json')
        })
        //重置新增POI的地图
        function resetPOIGoogleMapImg()
        {
            $("#newpoimap img").attr('src','');
        }

        //选中addressBox 设置
        $(document).on("click",".addressbox span",function(){
            var address = $(this).html();
            //查找当前需要赋值的input
            var addressBox = $(this).parent();
            var addressInput = $(addressBox).prev();
            var addressFormatInput = $(addressBox).next();
            setAddress(address,addressInput,addressFormatInput);
            //删除addressbox
            resetAddressBox();
        });
        //取消addressBox弹框
        $(document).on("click",'*:not(.addressbox_span)',function(event){
            resetAddressBox();
        })
        //重置addressBox
        function resetAddressBox()
        {
            $(".addressbox").html('');
        }

        function selectPoi2(e){
            changRightShowDataType();
            if (e.keyCode == 13) {
                var activeType = $(this).attr("data-type");
                var input = $(this).val();
                //其他
                if(activeType!==null && activeType==6){
                    hideRightMap();
                    if(input=="" || input==undefined){
                        return false;
                    }
                    var dayNum = schedule_id = input_poIid = active_id = 0;
                    var hidden_active = $(this).parent().parent();
                    dayNum = hidden_active.find(".active_id").attr('data-day')
                    schedule_id = hidden_active.find(".active_id").attr('data-sid')
                    active_id = hidden_active.find(".active_id").attr('value');
                    //赋值setTitle
                    $.post("/admin/product/updateActiveInfo", {active_id: active_id, title: input, activeType: activeType}, function (res) {
                        getRecommendList(input_poIid, dayNum, schedule_id, activeType, active_id,input)
                    }, 'json');
                }else{
                    var select = $(this).parent().parent().parent().find(".activeSelect_slt");
                    activeType = select.attr("data-type");
                    console.log(activeType);
                    //非POI 酒店 美食 停车场 加油站 购物 租车
                    if($.inArray(parseInt(activeType),global_active_type_arr)==-1){
                        return false;
                    }

                    var name = select.attr("name");
                    var numArr = name.split("_");
                    var active_id = numArr[1];
                    var poiSelect = $("#activeSelect_"+active_id);

                    var citySelect = $(this).parent().parent().parent().parent().find(".city_slt");
                    var city_id = citySelect.val();
                    var poi_type = activeType;//poi类型
                    var poi_type_name = getActiveTypeName(poi_type);
                    console.log(poi_type,poi_type_name);

                    $.ajax({
                        url:"{:url('getpoiByInput')}",
                        type:'post',
                        data:{input:input,city_id:city_id},
                        success:function(data) {
                            //无数据提示新增poi
                            if(data.length < 1 && input!="" && input!=undefined){
                                //询问框
                                var typeid = "";
                                layer.confirm('未检索到POI,是否创建类型为“'+poi_type_name+'”的'+input+'？', {
                                    btn: ['创建','取消'] //按钮
                                }, function(){
                                    //render新增poi模块
                                    //渲染newpoi地图
                                    //initialize_markerMap("newpoimap");
                                    //隐藏其他子节点
                                    $("#rightNewPOI").parent().children().hide();
                                    $("#rightNewPOI").show();
                                    $("#rightNewPOI").attr('active_id',active_id);
                                    //添加新的poi
                                    addNewPOi(poi_type,poi_type_name,input,city_id);
                                    poiInvertSelect();
                                    layer.msg('请在右侧添加数据');
                                    //隔一秒触发绑定事件
                                    timeoutId = setTimeout(function(){
                                        getAddressList($('#newpoi input[name=name]'));
                                    },1000)
                                },function(){
                                });
                            }
                            var html="<option value=''>请选择POI</option>";
                            for(var i=0;i<data.length;i++){
                                html += "<option value="+data[i]["id"]+">"+data[i]["name"]+"</option>";
                            }

                            poiSelect.html(html);

                            //重新渲染select
                            form.render('select');

                            poiSelect.next().addClass("layui-form-selected");
                            poiSelect.next().find("input[placeholder='POI']").focus();
                            poiSelect.next().find("input[placeholder='POI']").val(input);
                            poiInvertSelect();
                        }
                    });
                }

                return false;
            }
        }

        /*input失去焦点事件*/
        function selectPoi4(){
            changRightShowDataType();
            var activeType = $(this).attr("data-type");
            var input = $(this).val();
            //其他
            if(activeType==6){
                hideRightMap();
                if(input=="" || input==undefined){
                    return false;
                }
                var dayNum = schedule_id = input_poIid = active_id = 0;
                var hidden_active = $(this).parent().parent();
                dayNum = hidden_active.find(".active_id").attr('data-day')
                schedule_id = hidden_active.find(".active_id").attr('data-sid')
                active_id = hidden_active.find(".active_id").attr('value');
                //赋值setTitle
                $.post("/admin/product/updateActiveInfo", {active_id: active_id, title: input, activeType: activeType}, function (res) {
                    getRecommendList(input_poIid, dayNum, schedule_id, activeType, active_id,input)
                }, 'json');
            }
            return false;

        }
        //*****************************************************************
        ///*******************************右侧栏/**************************
        //*****************************************************************
        //选中图片功能
        $(".poiinfo").on("click",'.poi-detail-item-imgbox',function(){
            var shadow= $(this).find(".poi_img_shadow")
            if($(shadow).hasClass("poicheckeds")){
                $(shadow).removeClass("poicheckeds");
            }else{
                $(shadow).addClass("poicheckeds");
            }
        });

        //右侧 功能按钮
        $('.btnfix').click(function () {
            var shadow =$('.ActionButton')
            if($(shadow).hasClass("poibtnshow")){
                $(shadow).removeClass("poibtnshow");

            }else{
                $(shadow).addClass("poibtnshow");
            }
        });

        //下拉核价
        $(".dragDownPricing").click(function(){ //行程方案
            $(".dragUpPricing").removeClass("showTrip").addClass("hideTrip");
            $(".dragUpPricing").show();
            $(this).hide();
            $(".box-price").slideUp(250);
            $('.Travel-plan').show()
            $('.trafficCar').removeClass('hidden')
            sessionStorage.setItem("isClosePricing",false);
        });

        $(".dragUpPricing").click(function () { //核价信息
            $(this).hide();
            var loading = layer.load(2, {
                shade: [0.5, 'gray'],
                content: '加载中...',
                success: function (layero) {
                    layero.find('.layui-layer-content').css({
                        'padding-top': '39px',
                        'width': '60px'
                    });
                }
            });
            setTimeout(function () {
                window.location.reload();
                $(".box-price").removeClass("hideTrip").addClass("showTrip");
                $(".dragDownPricing").show();
                $(".box-price").slideDown(250);
                $('.Travel-plan').hide();
                sessionStorage.setItem("isClosePricing",true);
            },500)

        });

        // 上拉trip
        $(".dragUp").click(function(){
            $("#customer").removeClass("showTrip").addClass("hideTrip");
            $(".dragDown").show();
            $(this).hide();
            $("#customer").slideUp(250);
            sessionStorage.setItem("isClose",true);
        });

        $(".dragDown").click(function () {
            $("#customer").removeClass("hideTrip").addClass("showTrip");
            $(".dragUp").show();
            $(this).hide();
            $("#customer").slideDown(250);
            sessionStorage.setItem("isClose",false)
        });

        $(document).ready(function(){
            anchor = sessionStorage.getItem("tripmake_anchor");
            sessionStorage.setItem("tripmake_anchor","");
            {notempty name='$tripid'}
            if(anchor!="" && anchor!=undefined){
                window.location.href = "/admin/product/productmake?id="+{$tripid}+"#"+anchor;
            }else{
                if(location.hash!="" && location.hash!="#null"){
                    window.location.href = "/admin/product/productmake?id="+{$tripid}+"#";
                }
            }
            {/notempty}
        });

        //延迟绑定keyup事件
        window.onload = function(){
            poiInvertSelect;
            try {
                //初始化 天安门广场
                var amap = new AMap.Map('electronic_scenic_map', {
                    center:[116.397451,39.909187],
                    zoom:13
                });
                console.log(amap)
            }catch (e) {
                layer.msg('高德地图加载失败');
                return false;
            }
            //标记地图的点
            function marker(lat,lng,title='')
            {
                amap.clearMap();
                // 创建一个 Marker 实例：
                var marker = new AMap.Marker({
                    position: new AMap.LngLat(lng,lat),   // 经纬度对象，也可以是经纬度构成的一维数组[116.39, 39.9]
                    title: title
                });
                // 传入经纬度，设置地图中心点
                var position = new AMap.LngLat(lng,lat);  // 标准写法
                // 简写 var position = [116, 39];
                amap.setCenter(position);
                // 将创建的点标记添加到已有的地图实例：
                amap.add(marker);
            }
            //绑定匹配地址点击事件
            $(document).on('click','#electronic_addressbox .geoaddress',function(){
                getGeoAddressInfo(this);
                $('#electronic_addressbox').hide();
            })
            $(document).on('click',':not(#electronic_addressbox)',function (e) {
                if($('.addressbox').css('display') != 'none'){
                    $('.addressbox').hide();
                }
                e.stopPropagation();
            })
            $('.clearMap').click(function () {
                amap.clearMap();
                $('input[name=electronic_scenic_latlng]').val('');
            })
            //匹配地址点击获取地址信息
            function getGeoAddressInfo(that)
            {
                var location = $(that).attr('data-location');
                if(location=='' || location==undefined){ return false;}
                var location_arr = location.split(',');
                var name = $(that).text();

                //获取GEO地图信息
                AMap.WebService.get('https://restapi.amap.com/v3/geocode/regeo',{
                    location : location
                },function (error, result) {
                    //添加经纬度 location gid map_thumb_img
                    var formatted_address = result.regeocode.formatted_address;
                    var lat = location_arr[1];
                    var lng = location_arr[0];
                    var mapData = {
                        'name':name,
                        'address':formatted_address,
                        'lat':lat,
                        'lng':lng,
                        'map_type':'amap'
                    };
                    $('input[name=electronic_scenic_spots]').val(name);
                    $('input[name=electronic_scenic_latlng]').val(JSON.stringify(mapData));
                    //标记marker
                    marker(lat,lng);
                })
            }
            //延迟加载输入
            var timeoutId = 0;
            //通过输入内容匹配地址
            $(document).on('input','input[name=electronic_scenic_spots]',function (res) {
                clearTimeout(timeoutId);
                var value = $(this).val();
                if(value=='' || value==undefined){return false;}
                timeoutId = setTimeout(function(){
                    $('#electronic_addressbox').show();
                    getAddressList(value,$('#electronic_addressbox'));
                },1000)
            });

            //通过输入内容匹配地址
            function getAddressList(keyword,addressbox)
            {
                //匹配地址信息
                AMap.WebService.get('https://restapi.amap.com/v3/place/text',{
                    keywords : keyword
                },function (error, result) {
                    if(result.count < 1 || result.info!='OK'){
                        result.pois.push({name:'暂未匹配到地址！',location:''})
                    }
                    //获取数组进行渲染
                    var html = '';
                    var num = 0;
                    $.each(result.pois,function (i,v) {
                        if(num<5){
                            if(v.name!=''){
                                html += '<span class="geoaddress" data-location="'+v.location+'">'+v.name+'</span>';
                                num ++;
                            }
                        }else{
                            return false;
                        }
                    })
                    addressbox.children().remove();
                    addressbox.append(html);
                })

            }

            //初始化地图
            {if !empty($trip.electronic_scenic_latlng)}
            var electronic_scenic_latlng = {$trip.electronic_scenic_latlng};
            marker(electronic_scenic_latlng.lat,electronic_scenic_latlng.lng);
            {/if}


        }

        //ajax查询POI 反选城市
        function poiInvertSelect(){
            $(".selectpoilist input").on('keyup',selectPoi2);
            $(".selectpoilist input[name=other]").on('blur',selectPoi4);
        }
        //延迟加载输入
        var timeoutId = 0;
        $("#newpoi").on('input','input[name=name]',function(){
            console.log($(this).val())
            resetAddressBox();
            //添加addressbox
            clearTimeout(timeoutId);
            var value = $(this);
            timeoutId = setTimeout(function(){
                getAddressList(value);
            },1000)
        });


        //*****************************************************************
        ///**************************详细定制/**************************
        //*****************************************************************
        //显示/隐藏下拉 机场 酒店 详细定制补充信息
        $('body').on('click','.detail-create',function (event){
            event.stopPropagation();
            var shadow= $(this).parent().find(".detail-create-list")
            if($(shadow).hasClass("detailcustomshow")){
                $('.detailcustomshow').removeClass("detailcustomshow");
            }else{
                $('.detailcustomshow').removeClass("detailcustomshow");
                $(shadow).addClass("detailcustomshow");
            }
        });

        //点击酒店 机场动态创建信息
        $('body').on('click','.detail-create-list-item',function () {
            var typeId = $(this).val();
            var typeName = $(this).text();
            var activeType = $(this).parent().parent().find(".activeType");
            activeType.attr("value",typeId);
            $(this).parent().parent().find(".detail-create").html("<span>"+typeName+"</span>");

            var active_id = activeType.parent().parent().find(".active_id").attr("value");
            var dayNum = activeType.parent().parent().find(".active_id").attr("data-day");
            var schedule_id = activeType.parent().parent().find(".active_id").attr("data-sid");

            var city_id = $("select[name='city_"+active_id+"']").val();
            if(typeId !==6){
                var input=$(this).parent().parent().parent().find('.active_id').val();
                //判断是否为其他类型和非其他类型
                var active_html = '<select data-id="'+active_id+'" data-type="'+typeId+'" name="activeSelect_'+active_id+'" lay-filter="activeSelect" lay-search class="activeSelect_slt" id="activeSelect_'+active_id+'" data-day="'+dayNum+'" data-sid="'+schedule_id+'">';
            }else{
                var active_html = '<input name="other" data-id="'+active_id+'" data-type="6" value="" class="layui-input" placeholder="其他">';
            }
            $(this).parent().parent().next().next().children().remove();
            $(this).parent().parent().next().next().append(active_html);
            switch(typeId){
                case 1://POI

                    break;
                case 2://接机

                    break;
                case 3://送机

                    break;
                case 4://酒店

                    break;
                case 5://特色体验

                    break;
                case 6://其他

                    break;
            }

            if(city_id==undefined && city_id<=0){
                city_id = 0;
            }
            setActiveSelect(typeId,city_id,active_id);

            $('.detailcustomshow').removeClass("detailcustomshow");

            allSortKeyNum();
        });
        $(document).on("click",function(){
            $('.detailcustomshow').removeClass("detailcustomshow");
        })

        //添加新景点
        form.on('submit(newpoi)', function(data) {
            var lat = $("input[name=lat]").val();
            var lng = $("input[name=lng]").val();
            if(lat=="" || lng=="" || lat==undefined || lng==undefined){
                layer.msg("请填写英文名称匹配地址");
                return false;
            }
            var groupid = $('#newpoi select[name=groupid]').val();
            var type_id = $('#newpoi_typeid').val();
            //酒店分类是5 active分类是4
            if(type_id==5){
                type_id = 4;
            }
            var poi_load_index = layer.load(1);
            $.ajax({
                url:"{:url('admin/poi/addpoi')}",
                data:$('#newpoi').serialize(),
                type:'post',
                async: false,
                success:function(res) {
                    layer.msg(res.msg);
                    //添加成功
                    $("#rightNewPOI").hide();
                    var active_id = $("#rightNewPOI").attr("active_id");
                    //将新增poi放置到来时的地方
                    putNewPoiToDay(groupid,active_id,res.data.id,poi_load_index,type_id);
                }
            })
            return false;
        });

        function putNewPoiToDay(city_id,active_id,poi_id,poi_load_index,type_id){
            $.post("{:url('admin/product/getActiveData')}",{active_id:active_id,city_id:city_id,type_id:type_id},function(data){
                $.ajax({
                    url:"{:url('admin/product/setpoi')}",
                    data:{active_id:active_id,poiid:poi_id},
                    type:'post',
                    async: false,
                    success:function(res) {
                        layer.close(poi_load_index);
                        var html="<option value=''>POI</option>";
                        for(var i=0;i<data.length;i++){
                            html += "<option value="+data[i]["id"]+">"+data[i]["name"]+"</option>";
                        }
                        $("#activeSelect_"+active_id).html(html);
                        $("select[name=city_"+active_id+"]").val(city_id);
                        $("#activeSelect_"+active_id).val(poi_id);
                        //重新渲染select
                        form.render('select');
                        poiInvertSelect();
                    }
                });
            },"Json");
        }

        function addNewPOi(typeid,typename,poiname,city_id){
            if(typeid==4){
                typeid = 5;
            }
            $("#rightNewPOI").removeClass("hidden");
            //请空老数据
            $("#rightNewPOI button[type=reset]").click();
            resetPOIGoogleMapImg();
            $("#seeupload11").children().remove();
            $("#upload-thumb11").val("");
            //赋值类型
            $("#newpoi_typename").html(typename);
            $("#newpoi_typeid").val(typeid);
            $("#poichname").val(poiname);
            $("#newpoi_lat").val("");
            $("#newpoi_lng").val("");
            $("#newpoi_place_id").val("");
            //清空中文简介
            ue2.setContent("");
            //SearchAddress(poiname,$(".addressbox"));
            var select = $("select[name=groupid]");
            select.val(city_id);

            form.render();
        }

        $(document).on("click",".item-toggle-p",function(){
            var text = $(this).find(".dragModule").text();
            var expanded= $(this).attr('data-expanded')
            sessionStorage.setItem('expanded',expanded)
            if(text=="收起"){
                $(this).find(".dragModule").text("展开");
                $(this).next().slideUp(250);
            }else{
                var allToggle = $(".item-toggle-p");
                $.each(allToggle,function(i,v){
                    $(v).next().slideUp(250);
                    $(v).find(".dragModule").text("展开");
                });
                $(this).find(".dragModule").text("收起");
                $(this).next().slideDown(250);
            }
        });

        //更新active数据
        $(".updatePoiInfo_btn").click(function(){
            var form = $("#updateActiveInfo");
            var data = form.serialize();
            $.post("/admin/product/updateActiveInfo",data,function(res){
                var active_id = $("#updateActiveInfo input[name=active_id]").val();
                var updpoi_time = $("#updpoi_time").val();
                var title = $("#updateActiveInfo input[name=title]").val();
                $('.selectpoilist input[data-id='+active_id+'][name=other]').val(title);
                $("#"+active_id+"_aid").find(".timeInput").attr("value",updpoi_time);
                layer.msg(res.msg);
            },"json")
        });

        //删除上传的图片
        $('body').on("click",'#poiImgShow i',function(){
            var data_type = $(this).parent().parent().parent().attr("data-type");
            $(this).parent().remove();
            var img_str = '';
            var img_src = [];
            var img_arr = $("#poiImgShow img");
            if(img_arr.length>0){
                $.each(img_arr,function(i,v){
                    img_src.push($(v).attr('src'));
                });
                img_str = img_src.join(",");
            }else{
                img_str = "";
            }
            if($.inArray(parseInt(data_type),global_active_type_arr)>-1){
                $("input[name=poiImg]").val(img_str);
            }else if($.inArray(data_type,['6'])>-1){
                $("input[name=other_images]").val(img_str);
            }
        });

        var transport_day = 0;
        var transport_day_type = "";
        $(".trafficCar").click(function(){
            var shadow= $(this);
            $('.activetrafficCar').removeClass("activetrafficCar");
            $(shadow).addClass("activetrafficCar");
            transport_day = $(this).attr('data-id');
            transport_day_type = $(this).attr('data-type');
            changRightShowDataType("day")
        })
        //点击添加交通分类
        $("body").on('click','.transport_item',function(){
            var type_id = $(this).attr('data-type');
            var type_name = $(this).text();
            console.log(transport_day,type_id,transport_day_type);
            if(transport_day==0){
                layer.msg("请点击日期");return false;
            }
            var day_type_arr = [];
            if(transport_day_type!="" && transport_day_type!=undefined){
                day_type_arr = transport_day_type.split(',');
                if($.inArray(type_id,day_type_arr)!=-1){
                    layer.msg("请勿重复添加!");
                    return false;
                }
                if(day_type_arr.length>=3){
                    layer.msg("每日最多添加两种交通类型!");
                    return false;
                }

                // if($.inArray(transport_day_type,['3','4','5','6','7'])>-1 &&  $.inArray(type_id,['3','4','5','6','7'])>-1){
                //     layer.msg(type_name+"不能和已选类型同时存在!");
                //     return false;
                // }
            }
            day_type_arr.push(type_id)
            transport_day_type = day_type_arr.join(',');
            var upd_trans_load_index = 0;
            $.post("/admin/product/updTransportType",{schedule_id:transport_day,day_type:transport_day_type},function(data){
                layer.msg(data.msg);
                if(data.code==1){
                    //push node
                    var html = '<p class="layui-btn-info layui-btn layui-btn-xs layui-btn-normal trafficCar_item" data-id="'+type_id+'">'+type_name+'<i class="layui-icon"></i></p>\n';
                    $(".trafficCar_"+transport_day).append(html);
                    $(".trafficCar_"+transport_day).attr("data-type",transport_day_type);
                }
            },"json");

        })
        //点击删除交通分类
        $("body").on('click','.trafficCar_item',function(){
            var _that = this;
            var my_id = $(this).attr("data-id");
            var trans_del_type = $(this).parent().attr("data-type");
            var day_id = $(this).parent().attr("data-id");
            var trans_del_type_arr = trans_del_type.split(',');
            var trans_del_day_type =  '';
            console.log(my_id,trans_del_type,trans_del_type_arr,$.inArray(parseInt(my_id),trans_del_type_arr))
            if($.inArray(my_id,trans_del_type_arr)==-1){
                layer.msg("删除失败");return false;
            }
            trans_del_type_arr.splice($.inArray(my_id,trans_del_type_arr),1);
            if(trans_del_type_arr.length<1){
                trans_del_day_type = "";
            }else{
                trans_del_day_type = trans_del_type_arr.join(",");
            }
            $.post("/admin/product/updTransportType",{schedule_id:day_id,day_type:trans_del_day_type,'upd_type':'delete'},function(data){
                layer.msg(data.msg);
                if(data.code==1){
                    //push node
                    $(_that).remove();
                    $(".trafficCar_"+transport_day).attr("data-type",trans_del_day_type);
                    transport_day_type = trans_del_day_type;
                }
            },"json");
        })
        //切换右侧数据栏
        function changRightShowDataType(type="poi"){
            if(type=='poi'){
                $('.activetrafficCar').removeClass("activetrafficCar"); //去掉添加交通类型的边框
                $("#poiDataInfo").show();
                $("#dayDataInfo").hide();
            }else{
                $("#poiDataInfo").hide();
                $("#dayDataInfo").show();
            }
        }

        $(".trans_type_close").click(function(){
            $(this).parent().parent().hide();
        });

        //一键切换快速 -显示核价部分
        $('.ManualSwitch').click(function (){
            if($('.box-price').hasClass("switcherset")){
                $('.box').hide()  //遮罩为打开
                // layer.msg('底部核价已隐藏')
                $(".box-price").removeClass("switcherset")
                $(".box-price").hide(); //核价板块
                $('.Travel-plan').show() //行程方案 板块
                $(".dragUpPricing").hide(); //核价信息 箭头
                $(".dragDownPricing").hide(); //行程方案 箭头
                $('.ActionButton').removeClass("poibtnshow");
                $('.trafficCar').addClass('hidden')
                $('.ManualSwitch-span').html('显示核价')
//                sessionStorage.setItem("isClosePricing",true)
//                 $(".trafficCar").eq(0).css('backgroundColor','#eee');
                $(".trafficCar").eq(0).prev().css('opacity','1');
                $(".trafficCar").eq(0).parent().css('z-index','0');
                $("#dayDataInfo").hide()
            }else{
                // layer.msg('底部核价已显示')
                $('.box-price').addClass("switcherset"); //删除
                $(".box-price").hide();  //核价板块
                $('.Travel-plan').show() //行程方案 板块
                $(".dragUpPricing").show();
                $(".dragDownPricing").hide();
                // sessionStorage.setItem("isClosePricing",true)
                $('.ActionButton').removeClass("poibtnshow");
                // window.location.reload()
                $('.trafficCar').removeClass('hidden')
                $('.ManualSwitch-span').html('显示定制')
//                sessionStorage.setItem("isClosePricing",false)
                //默认选中第一个交通标签
                $(".trafficCar").eq(0).click();
                //显示遮罩
                if(is_show_shadow==1){
                    $(".trafficCar").eq(0).parent().css('z-index','12');
                    $(".trafficCar").eq(0).css('backgroundColor','#fff');
                    $(".trafficCar").eq(0).prev().css('opacity','0.3');
                    $('.box').show()  //遮罩为打开
                }
            }
        });
        // 点击遮罩关掉
        $('.box').click(function () {
            $(this).hide()
            $(".trafficCar").eq(0).parent().css('z-index','0');
            // $(".trafficCar").eq(0).css('backgroundColor','#eee');
            $(".trafficCar").eq(0).prev().css('opacity','1');
        });

        //选择采购渠道
        form.on('select(buyType)', function(param){
            var type = param.value;
            if(type=='driver'){
                $(".supplier_div").hide();
                $(".driver_div").show();
                $("#supplier_id").val('');
                $("#supplier_item_code").val('');
            }else{
                $(".supplier_div").show();
                $(".driver_div").hide();
                $("#driver_id").val('');
                $("#driver_id").html('<option value="" disabled selected hidden>请输入司导姓名后回车查询</option>');
                $("#driver_str").val('');
                $(".driver_div").find("input").val('');
            }
            form.render('select');
            bindDriverFunc();
            return false;
        });

        form.on('select(driver_id)', function(param){
            var text = param.elem[param.elem.selectedIndex].text;
            $("#driver_str").attr("value",text);
            return false;
        });

        //查询司导
        function bindDriverFunc(){
            $(".driver_div input").on('keyup',driverFind);
        }
        function driverFind(e) {
            if (e.keyCode == 13) {
                var driver_name = $(this).val();
                $.ajax({
                    url:"{:url('admin/product/getDriverData')}",
                    data:{name:driver_name},
                    type:'post',
                    success:function(data) {
                        if(data.length<1){
                            return false;
                        }
                        var html="<option value=''>请选择司导</option>";
                        for(var i=0;i<data.length;i++){
                            html += "<option value="+data[i]["id"]+">"+data[i]['profile']["name"]+"，"+data[i]['username']+"（"+data[i]['profile']['cityString']+"）"+"</option>";
                        }

                        $("#driver_id").html(html);

                        //重新渲染select
                        form.render('select');
                        $("#driver_id").next().addClass("layui-form-selected");
                        $("#driver_id").next().find("input").focus();
                        $("#driver_id").next().find("input").val(driver_name);
                        bindDriverFunc();
                    }
                });
            }
            return false;
        }
        bindDriverFunc();

        //启用门票
        $(document).on("click",".ticketBtn",function(){
            var active_id = $(this).parent().parent().parent().find("input[name='active_id']").val();
            var value = $(this).attr("data-value");
            var that = $(this);
            $.ajax({
                url:"{:url('admin/product/setTicketStatus')}",
                data:{active_id:active_id,value:value},
                type:'post',
                success:function(res) {
                    layer.msg(res.msg);
                    if(res.code == 1) {
                        if(value==0){
                            that.attr("data-value",1);
                            that.text("启用中");
                            that.removeClass("layui-btn-danger");
                        }else{
                            that.attr("data-value",0);
                            that.text("未启用");
                            that.addClass("layui-btn-danger");
                        }
                    }
                }
            });

            return false;
        });


        //标签
        form.on('select(addtrips)', function(data){
            var tripid = data.value;
            $("#addtrips").attr("data-id",tripid);
        });
        $("#addtrips").on("click",function () {
            var tripid= $("#addtrips").attr("data-id");
            var tripids=$("#tripids").val();
            var ids=tripids.split(",");

            if (tripid==999999){
                tripids=999999;
                var tripspan='<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="999999" style="margin: 5px 10px">全部<i class="layui-icon"></i></span>';
                $("#tripnames").html(tripspan);
            }else{
                for(var i=0 ; i < ids.length; i++){
                    if(tripid==ids[i]){
                        layer.msg("不能重复添加商品");
                        return false;
                    }
                    if(ids[i]==999999){
                        tripids=999999;
                        var tripspan='<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="999999" style="margin: 5px 10px">全部<i class="layui-icon"></i></span>';
                        $("#tripnames").html(tripspan);
                        $("#tripids").val(tripids);
                        return false;
                    }
                }
                var tripname="";
                $("#triptag").find("option").each(function () {
                    if($(this).val()==tripid){
                        tripname=$(this).html();
                    }
                });

                var tripspan='<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="'+tripid+'" style="margin: 5px 10px">'+tripname+'<i class="layui-icon"></i></span>';
                if(!tripids){
                    tripids+=tripid;
                }else{
                    tripids+=','+tripid;
                }
                $("#tripnames").append(tripspan);
            }
            $("#tripids").val(tripids);
        });
        $(document).on("click",'.deltripspan',function () {
            var dataid=$(this).attr("data-id");
            var tripids=$("#tripids").val();
            var ids=tripids.split(",");
            var newid="";
            for(var i=0 ; i < ids.length; i++){
                if(ids[i]&&dataid!=ids[i]){
                    if(!newid){
                        newid+=ids[i];
                    }else{
                        newid+=","+ids[i];
                    }
                }
            }
            $("#tripids").val(newid);
            $(this).remove();
        });

        //新增标签
        $("#addNewTag").click(function(){
            var tag_name = $(this).parent().prev().prev().find('input').val();
            layer.open({
                type: 1,
                title:'新增TAG',
                area: ['40%', '20%'],
                btn: ['保存', '取消'],
                content: '<form class="layui-form" id="addNewtagForm">\n'+
                '<div class="layui-form-item">\n'+
                '<label class="layui-form-label">TAG名称</label>\n'+
                '<div class="layui-input-inline" style="width: 300px">\n'+
                '<input name="tag_name" lay-verify="required" value="'+tag_name+'" placeholder="请输入" autocomplete="off" class="layui-input" type="text">\n'+
                '<input name="tag_type" value="2" type="hidden">\n'+
                '<input name="tag_status" value="1" type="hidden">\n'+
                '</div>\n'+
                '</div>\n',
                yes: function(index, layero) {
                    var tag_name = $('input[name=tag_name]').val();
                    if(tag_name=='' || tag_name==undefined){
                        layer.msg('请填写标签名称');return false;
                    }
                    $.post('{:url("admin/taglable/addtag")}',$('#addNewtagForm').serialize(),function(res){
                        layer.msg(res.msg);
                        if(res.code>0){
                            tagInfo = res.data;
                            $("#triptag").append('<option value="'+tagInfo.id+'" selected>'+tagInfo.name+'</option>');
                            form.render('select');

                            $("#addtrips").attr('data-id',tagInfo.id);
                            $("#addtrips").attr('data-name',tagInfo.name);
                            $("#addtrips").click();
                            setTimeout(function(){
                                layer.close(index);
                            },1000)
                        }
                    },'json')
                }
            });
        })

        //切换文本方案和节点方案
        $(".changeTextPlan").click(function(){
            var value =  $(this).attr('data');
            if(value=='text'){
                var is_text_plan = 1;
            }else if(value=='poi'){
                var is_text_plan = 0;
            }else{
                layer.msg('切换行程方案错误！');return false;
            }
            var tipMsg = is_text_plan < 1 ? '确认切换为节点方案？<br>您将按照选择POI方式编辑线路！' : '确认切换为文本方案？<br>您将以编辑文本的方式编辑线路！';
            layer.confirm(tipMsg,function(){
                var productId = $("input[name=tripid]").val();
                var load_index = layer.load(2);
                $.post('{:url("admin/product/changeTextPlan")}',{is_text_plan:is_text_plan,id:productId},function (res) {
                    layer.close(load_index);
                    layer.msg(res.msg);
                    if(res.code > 0){
                        setTimeout(function(){
                            window.location.reload();
                        },1000)
                    }
                },'json')
            })
        })
        // 自产自销关联团期展示产品
        form.on('radio(allow_everyone_quote)',function (data) {
            parseInt(data.value) > 0 ?
                $('#is_group_exhibition_module').hide() :
                $('#is_group_exhibition_module').show() ;

        })

        //验证tplId
        $('.verifyTplId').click(function () {
            var tplID = $('input[name=electronic_tpl_id]').val();
            if(tplID=='' || tplID==undefined){layer.msg('请输入模板ID');return false;}
            var index = layer.load(2);
            $.post("{:url('admin/product/verifyTplId')}",{tplId:tplID},function (res) {
                layer.close(index);
                layer.msg(res.msg);
                if(res.code > 0){
                    layer.open({
                        type:2,
                        title:'商品信息',
                        area: ['80%','80%'],
                        content:res.data.link,
                        end:function () {

                        }
                    })
                }
            },'json');
            return false;
        })
    });
    //设置自动更新产品信息
    function autoUpdateProductInfo(param){
        $.post('{:url("admin/product/ajaxUpdateProductInfo")}',param,function (res) {
            layer.closeAll('loading');
            if(res.code<1){layer.msg(res.msg)}else{
                if(param.hasOwnProperty('sale_details') || param.hasOwnProperty('text_plan')){
                    if(showAutoUpdateMsg){layer.msg('success')};
                    showAutoUpdateMsg = false;
                }

            }
        })
    }
    //重新排序序号
    function sortKeyNumber(schedule_id){
        var newNum = 1;
        $("#li_"+schedule_id).find(".messdiv").each(function(){
            var activeType = $(this).find(".activeType").attr("value");
            activeType = parseInt(activeType);
            if(activeType!==6){
                $(this).find(".keyNumber").text(newNum);
                newNum++;
            }
        });
    }

    //全部重新排序序号
    function allSortKeyNum(){
        $(".schedule_id").each(function(){
            var schedule_id = $(this).attr("value");
            sortKeyNumber(schedule_id);
        });
    }

    allSortKeyNum();

    //获取节点前后距离
    function getPointDistace(active_id,schedule_id){
        $.ajax({
            url:"{:url('admin/product/getPointDistance')}",
            data:{active_id:active_id,groupid:schedule_id},
            type:'post',
            async: false,
            success:function(data) {
                for(var i=0;i<data.length;i++){
                    var thisDistance = $("#activeSelect_"+data[i]['id']).parent().parent().next(".distance-list");
                    var html = '';
                    if(data[i]['distance'] > 0){
                        html = "<i class='layui-icon'>&#xe715;</i>相距"+data[i]['distance']+"公里";
                    }
                    thisDistance.find(".distance-list-car").html(html);
                }
            }
        });

        return false;
    }
</script>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;
        upload.render({
            elem: '#upload11'
            ,url: "{:url('common/upload')}"
            ,multiple: true
            ,accept:"images"
            ,size:"50000"
            ,done: function(res){
                //上传完毕回调
                layer.closeAll('loading');
                if(res.code == 2) {
                    $('#seeupload11').append('<span class="uploadimgbox"><img class="layui-upload-img" src="'+res.src+'"><i class="layui-icon">&#x1006;</i></span>');
                    $('#upload-thumb11').val($('#upload-thumb11').val()+","+res.src);
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error: function(){
                //请求异常回调
                //演示失败状态，并实现重传
                layer.closeAll('loading');
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
            ,before:function () {
                layer.load(2);
            }
        });
        upload.render({
            elem: '#otherimg_btn' //绑定元素
            ,url: "{:url('common/upload')}" //上传接口
            ,multiple: true
            ,accept:"images"
            ,size:"50000"
            ,done: function(result){
                //上传完毕回调
                layer.closeAll('loading');
                if(result.code == 2) {
                    var src = result.src;
                    var html = '<span><img class="layui-upload-img" src="' + src + '" style="width:85px;padding:5px;"><i class="layui-icon">&#x1006;</i></span>';
                    $("#poiImgShow").append(html);
                    var img = $("input[name=other_images]").val();
                    $("input[name=other_images]").val(img + "," + src);
                    layer.msg("上传成功");
                }else{
                    layer.msg(result.msg);
                }
            }
            ,error: function(){
                //请求异常回调
                layer.closeAll('loading');
                layer.msg("上传失败");
                return false;
            }
            ,before:function () {
                layer.load(2);
            }
        });
        {if $existGoods}
        //执行实例图片
        upload.render({
            elem: '#upload1'
            ,url: "{:url('common/upload')}"
            ,multiple: true
            ,accept:"images"
            ,size:"50000"
            ,done: function(res){
                //上传完毕回调
                layer.closeAll('loading');
                if(res.code == 2) {
                    $('#seeupload1').append('<span class="uploadimgbox list-group-item"><img class="layui-upload-img" src="'+res.src+'"><i class="layui-icon">&#x1006;</i></span>');
                    $('#upload-thumb1').val($('#upload-thumb1').val()+","+res.src);
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error: function(){
                //请求异常回调
                //演示失败状态，并实现重传
                layer.closeAll('loading');
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
            ,before:function(){
                layer.load(2);
            }
        });
        //执行实例视频
        upload.render({
            elem: '#test5'
            ,url: "{:url('common/upload')}"
            ,accept: 'video' //视频
            ,size:'65536'
            ,done: function(res){
                layer.closeAll('loading');
                if(res.code == 2) {
                    layer.msg("文件上传成功");
                    $("#seevideo").html('<video controls style="width:50%">\n' +
                        '<source  src="'+res.src+'">\n' +
                        '</video><i class="layui-icon deleteVideo" style="vertical-align:top;">&#x1006;</i>');
                    $("#upload-video").val(res.src);
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error:function () {
                layer.closeAll('loading');
            }
            ,before:function () {
                layer.load(2);
            }
        });

        $("#seevideo").on('click','.deleteVideo',function () {
            $(this).prev().remove();$(this).remove();
            $("#upload-video").val("");
        })
        {/if}
    });

    $("#seeupload11").on("click",".layui-icon",function(){
        $(this).parent().remove();
        thumb("seeupload11",11);
    });
    $("#seeupload1").on("click",".layui-icon",function(){
        $(this).parent().remove();
        thumb("seeupload1",1);
    });
    function thumb(obj,n){
        var thumbs="";
        $("#"+obj).find("img").each(function(){
            var url=$(this).attr("src");
            thumbs+=","+url;
        });
        $("#upload-thumb"+n).val(thumbs);
    }
</script>
<script>
    //核价
    /*转换正负整数*/
    function parseInputNumber(_that){
        var str = $(_that).val();
        if(str.indexOf(".")>-1){
            $(_that).val(str.slice(0,str.indexOf(".")));
        }
    }
    //航班信息提交
    $(".airportDetail,.airportPrice").bind("input propertychange", function () {
        var schedule_id = $(this).parent().parent().parent().attr("data-id");
        var arr = [];
        if($(this).attr('type')=='number'){
            parseInputNumber(this)
        }
        $(this).parent().parent().find(".airportDiv").each(function(){
            var dataId = $(this).find(".airportDetail").attr("data-id");
            var airportDetail = $(this).find(".airportDetail").val() || "";
            var airportPrice = $(this).find(".airportPrice").val() || 0;
            var airArr = [dataId,airportDetail,airportPrice];
            arr.push(airArr);
        });

        $.ajax({
            url:"{:url('admin/product/changePriceTable')}",
            data:{type:'airport',schedule_id:schedule_id,name:'airport_json',data:arr},
            type:'post',
            success:function(res) {
                if(res.code!==1){
                    layer.msg(res.msg);
                }
            }
        });

        countPrice();

        return false;
    });
    //酒店信息提交
    $(".hotelDetail,.hotelPrice,.totalHotelPrice").bind("input propertychange", function () {
        var name = $(this).attr("name");
        var value = $(this).val();
        var schedule_id;
        var alldayhotel;
        if(name=='hotelDetail'){
            schedule_id = $(this).parent().parent().attr("data-id");
            alldayhotel = $(this).parent().find(".alldayhotel").attr("value");
        }else if(name=='totalHotelPrice'){
            schedule_id = $(this).parent().parent().parent().attr("data-id");
            alldayhotel = $(this).parent().parent().find(".alldayhotel").attr("value");
            var totalPrice = $(this).val();
            var hotelPrice = $(this).parent().find(".hotelPrice");
            value = 0;
            if(totalPrice>0 && totalPrice!==''){
                var num = hotelPrice.attr("data-num");
                value = Math.round(totalPrice/num);
                hotelPrice.val(value);
            }else{
                hotelPrice.val('');
            }
            name = 'hotelPrice';
            countPrice();
        }else{
            schedule_id = $(this).parent().parent().parent().attr("data-id");
            alldayhotel = $(this).parent().parent().find(".alldayhotel").attr("value");

            parseInputNumber(this);
            countHotelPrice();
            countPrice();
        }

        $.ajax({
            url:"{:url('admin/product/changePriceTable')}",
            data:{type:'hotel',schedule_id:schedule_id,name:name,data:value,alldayhotel:alldayhotel},
            type:'post',
            success:function(res) {
                if(res.code!==1){
                    layer.msg(res.msg);
                }
            }
        });

        return false;
    });
    //租车信息提交
    $(".driveDetail,.drivePrice").bind("input propertychange", function () {
        var name = $(this).attr("name");
        var value = $(this).val();
        var schedule_id = $(this).parent().parent().attr("data-id");
        var alldaydrive = $(this).parent().find(".alldaydrive").attr("value");
        if(name=='drivePrice'){
            parseInputNumber(this);
            countPrice();
        }

        $.ajax({
            url:"{:url('admin/product/changePriceTable')}",
            data:{type:'drive',schedule_id:schedule_id,name:name,data:value,alldaydrive:alldaydrive},
            type:'post',
            success:function(res) {
                if(res.code!==1){
                    layer.msg(res.msg);
                }
            }
        });

        return false;
    });
    //其他信息提交
    $(".ajaxSubmit").bind("input propertychange", function () {
        var name = $(this).attr("name");
        var value = $(this).val();
        var schedule_id = $(this).parent().parent().attr("data-id");
        if($(this).attr('type')=='number'){
            parseInputNumber(this)
        }
        $.ajax({
            url:"{:url('admin/product/changePriceTable')}",
            data:{type:'other',schedule_id:schedule_id,name:name,data:value},
            type:'post',
            success:function(res) {
                if(res.code!==1){
                    layer.msg(res.msg);
                }
            }
        });

        countPrice();

        return false;
    });

    function countHotelPrice(){
        $(".hotelPrice").each(function(){
            var hotelPrice = $(this);
            var value = hotelPrice.val();
            if(value>0 && value!==''){
                var num = hotelPrice.attr("data-num");
                var totalHotelPrice = value*num;
                hotelPrice.siblings(".totalHotelPrice").val(totalHotelPrice);
            }else{
                hotelPrice.siblings(".totalHotelPrice").val('');
            }
        });
    }

    //加和 价格
    function countPrice(){
        //航班报价
        var airportPrice = 0;
        var airportPrice_ipt = $("input[name='airportPrice_ipt']").val();
        var airportPrice_btn = $(".airportPrice_btn ").attr("value");
        if(airportPrice_btn>0){
            if(airportPrice_ipt>0){

            }else{
                airportPrice_ipt = 0;
            }
            airportPrice = parseInt(airportPrice_ipt);
        }else{
            $(".airportPrice").each(function(){
                var value = $(this).val();
                value = parseInt(value);
                if(value>0 && value!==''){
                    airportPrice = airportPrice+value;
                }
            });
            $("#count_airportPrice").html(airportPrice);
        }

        //酒店报价
        var count_hotelPrice = 0;
        var hotelPrice_ipt = $("input[name='hotelPrice_ipt']").val();
        var hotelPrice_btn = $(".hotelPrice_btn ").attr("value");
        if(hotelPrice_btn>0){
            if(hotelPrice_ipt>0){

            }else{
                hotelPrice_ipt = 0;
            }
            count_hotelPrice = parseInt(hotelPrice_ipt);
        }else{
            $(".totalHotelPrice").each(function(){
                var value = $(this).val();
                value = parseInt(value);
                if(value>0 && value!==''){
                    count_hotelPrice = count_hotelPrice+value;
                }
            });
            $("#count_hotelPrice").html(count_hotelPrice);
        }


        //租车报价
        var count_drivePrice = 0;
        var drivePrice_ipt = $("input[name='drivePrice_ipt']").val();
        var drivePrice_btn = $(".drivePrice_btn ").attr("value");
        if(drivePrice_btn>0){
            if(drivePrice_ipt>0){

            }else{
                drivePrice_ipt = 0;
            }
            count_drivePrice = parseInt(drivePrice_ipt);
        }else{
            $(".drivePrice").each(function(){
                var value = $(this).val();
                value = parseInt(value);
                if(value>0 && value!==''){
                    count_drivePrice = count_drivePrice+value;
                }
            });
            $("#count_drivePrice").html(count_drivePrice);
        }


        //包车报价
        var count_carPrice = 0;
        var carPrice_ipt = $("input[name='carPrice_ipt']").val();
        var carPrice_btn = $(".carPrice_btn ").attr("value");
        if(carPrice_btn>0){
            if(carPrice_ipt>0){

            }else{
                carPrice_ipt = 0;
            }
            count_carPrice = parseInt(carPrice_ipt);
        }else{
            $(".totalCarPrice").each(function(){
                var value = $(this).html();
                value = parseInt(value);
                if(value>0 && value!==''){
                    count_carPrice = count_carPrice+value;
                }
            });
            $("#count_carPrice").html(count_carPrice);
        }



        //门票报价
        var count_ticketPrice = 0;
        $(".totalTicketPrice").each(function(){
            var value = $(this).val();
            value = parseInt(value);
            if(value>0 && value!==''){
                count_ticketPrice = count_ticketPrice+value;
            }
        });
        $("#count_ticketPrice").html(count_ticketPrice);


        //保险报价
        var count_insurancePrice = 0;
        $(".totalInsurancePrice").each(function(){
            var value = $(this).val();
            value = parseInt(value);
            if(value>0 && value!==''){
                count_insurancePrice = count_insurancePrice+value;
            }
        });
        $("#count_insurancePrice").html(count_insurancePrice);


        //附加报价
        var count_extraPrice = 0;
        $(".totalExtraPrice").each(function(){
            var value = $(this).val();
            if(value.substr(0,1)=='-'){
                value = value.substr(1,value.length);
                value = parseInt(value);
                count_extraPrice = count_extraPrice-value;
            }else{
                value = parseInt(value);
                if(value>0 && value!==''){
                    count_extraPrice = count_extraPrice+value;
                }
            }
        });
        $("#count_extraPrice").html(count_extraPrice);


        //总价
        var totalPrice = airportPrice + count_hotelPrice + count_carPrice + count_ticketPrice + count_drivePrice + count_insurancePrice + count_extraPrice;
        $("#totalPrice").html(totalPrice);


        var tripid = $("#tripid").attr("value");
        $.ajax({
            url:"{:url('admin/product/saveTotalPrice')}",
            data:{
                tripid:tripid,
                total_price:totalPrice,
                airportPrice_btn:airportPrice_btn,
                hotelPrice_btn:hotelPrice_btn,
                drivePrice_btn:drivePrice_btn,
                carPrice_btn:carPrice_btn,
                totalAirportPrice:airportPrice,
                totalHotelPrice:count_hotelPrice,
                totalDrivePrice:count_drivePrice,
                totalTransPrice:count_carPrice,
                totalTicketPrice:count_ticketPrice,
                totalExtraPrice:count_extraPrice
            },
            type:'post',
            success:function(res) {
                if(res.code!==1){
                    layer.msg(res.msg);
                }
            }
        });
    }
    function transBtn(){
        var airportPrice_btn  = $(".airportPrice_btn").attr("value");
        var hotelPrice_btn  = $(".hotelPrice_btn").attr("value");
        var drivePrice_btn  = $(".drivePrice_btn").attr("value");
        var carPrice_btn  = $(".carPrice_btn").attr("value");

        if(airportPrice_btn<1){
            $(".airportPrice_btn").removeClass("layui-btn-warm");
            $(".airportPrice_ipt").hide();
            $(".airportPrice_count_ipt").show();
        }else{
            $(".airportPrice_btn").addClass("layui-btn-warm");
            $(".airportPrice_ipt").show();
            $(".airportPrice_count_ipt").hide();
        }
        if(hotelPrice_btn<1){
            $(".hotelPrice_btn").removeClass("layui-btn-warm");
            $(".hotelPrice_ipt").hide();
            $(".hotelPrice_count_ipt").show();
        }else{
            $(".hotelPrice_btn").addClass("layui-btn-warm");
            $(".hotelPrice_ipt").show();
            $(".hotelPrice_count_ipt").hide();
        }
        if(drivePrice_btn<1){
            $(".drivePrice_btn").removeClass("layui-btn-warm");
            $(".drivePrice_ipt").hide();
            $(".drivePrice_count_ipt").show();
        }else{
            $(".drivePrice_btn").addClass("layui-btn-warm");
            $(".drivePrice_ipt").show();
            $(".drivePrice_count_ipt").hide();
        }
        if(carPrice_btn<1){
            $(".carPrice_btn").removeClass("layui-btn-warm");
            $(".carPrice_ipt").hide();
            $(".carPrice_count_ipt").show();
        }else{
            $(".carPrice_btn").addClass("layui-btn-warm");
            $(".carPrice_ipt").show();
            $(".carPrice_count_ipt").hide();
        }
        countPrice();
    }
    var isClosePricingFlag = sessionStorage.getItem("isClosePricing");
    if(isClosePricingFlag=='true'){
        countHotelPrice();
        transBtn();
    }

    //机票自填
    $(".airportPrice_btn").click(function(){
        var value = $(this).attr("value");
        if(value>0){
            $(this).removeClass("layui-btn-warm");
            $(this).attr("value",0);
            $(".airportPrice_ipt").hide();
            $(".airportPrice_count_ipt").show();
        }else{
            $(this).addClass("layui-btn-warm");
            $(this).attr("value",1);
            $(".airportPrice_ipt").show();
            $(".airportPrice_count_ipt").hide();
        }
        countPrice();
    });
    $("input[name='airportPrice_ipt']").bind('input propertychange',function(){
        countPrice();
    });

    //酒店自填
    $(".hotelPrice_btn").click(function(){
        var value = $(this).attr("value");
        if(value>0){
            $(this).removeClass("layui-btn-warm");
            $(this).attr("value",0);
            $(".hotelPrice_ipt").hide();
            $(".hotelPrice_count_ipt").show();
        }else{
            $(this).addClass("layui-btn-warm");
            $(this).attr("value",1);
            $(".hotelPrice_ipt").show();
            $(".hotelPrice_count_ipt").hide();
        }
        countPrice();
    });
    $("input[name='hotelPrice_ipt']").bind('input propertychange',function(){
        countPrice();
    });

    //租车自填
    $(".drivePrice_btn").click(function(){
        var value = $(this).attr("value");
        if(value>0){
            $(this).removeClass("layui-btn-warm");
            $(this).attr("value",0);
            $(".drivePrice_ipt").hide();
            $(".drivePrice_count_ipt").show();
        }else{
            $(this).addClass("layui-btn-warm");
            $(this).attr("value",1);
            $(".drivePrice_ipt").show();
            $(".drivePrice_count_ipt").hide();
        }
        countPrice();
    });
    $("input[name='drivePrice_ipt']").bind('input propertychange',function(){
        countPrice();
    });

    //包车自填
    $(".carPrice_btn").click(function(){
        var value = $(this).attr("value");
        if(value>0){
            $(this).removeClass("layui-btn-warm");
            $(this).attr("value",0);
            $(".carPrice_ipt").hide();
            $(".carPrice_count_ipt").show();
        }else{
            $(this).addClass("layui-btn-warm");
            $(this).attr("value",1);
            $(".carPrice_ipt").show();
            $(".carPrice_count_ipt").hide();
        }
        countPrice();
    });
    $("input[name='carPrice_ipt']").bind('input propertychange',function(){
        countPrice();
    });

    //删除司导返程
    $(".deleteReturnJourney").click(function(){
        var day_id = $(this).attr('data-day');
        layer.confirm('确认删除司导返程?', {icon: 3, title:'提示'}, function(index){
            //不设置司导返程
            $.post("/admin/product/updReturnJourney",{day_id:day_id,status:1},function(data){
                layer.msg(data.msg);
                if(data.code==1){
                    setTimeout(function(){
                        window.location.reload();
                    })
                }
            },'json')
        })
    })
    //删除司导返程
    $(".setReturnJourney").click(function(){
        var day_id = $(this).attr('data-day');
        layer.confirm('新增司导返程?', {icon: 3, title:'提示'}, function(index){
            //不设置司导返程
            $.post("/admin/product/updReturnJourney",{day_id:day_id,status:2},function(data){
                layer.msg(data.msg);
                if(data.code==1){
                    setTimeout(function(){
                        window.location.reload();
                    })
                }
            },'json')
            // layer.close(index);
        });

    })

</script>
<script>
    function transInput(){
        //转换航班信息
        $(".airportDiv").each(function(){
            var html = '';
            var airportDetail = $(this).find(".airportDetail").val();
            var airportPrice = $(this).find(".airportPrice").val();
            if(airportDetail!==undefined && airportDetail!==''){
                html += "明细："+airportDetail;
            }
            if(airportPrice!==undefined && airportPrice!==''){
                html += "<br style='mso-data-placement:same-cell;'/> 报价：￥"+airportPrice;
            }
            $(this).parent().html(html);
        });

        //转换酒店信息
        $(".hotelDetail").each(function(){
            var html = '';
            var hotelDetail = $(this).val();
            var hotelPrice = $(this).parent().find(".hotel-dealis").find(".hotelPrice").val();
            var dataNum = $(this).parent().find(".hotel-dealis").find(".hotelPrice").attr("data-num");
            var totalHotelPrice = $(this).parent().find(".hotel-dealis").find(".totalHotelPrice").val();
            if(hotelDetail!==undefined && hotelDetail!==''){
                html += "明细："+hotelDetail;
            }
            if(hotelPrice!==undefined && hotelPrice!==''){
                html += "<br style='mso-data-placement:same-cell;'/> 报价：￥"+hotelPrice+" *"+dataNum+"天 ="+" ￥"+totalHotelPrice;
            }
            $(this).parent().html(html);
        });

        //转换租车信息
        $(".driveDetail").each(function(){
            var html = '';
            var driveDetail = $(this).val();
            var drivePrice = $(this).parent().find(".drivePrice").val();
            if(driveDetail!==undefined && driveDetail!==''){
                html += "明细："+driveDetail;
            }
            if(drivePrice!==undefined && drivePrice!==''){
                html += "<br style='mso-data-placement:same-cell;'/> 报价：￥"+drivePrice;
            }
            $(this).parent().html(html);
        });

        //转换包车信息
        $(".totalCarPrice").each(function(){
            var html = '';
            var totalCarPrice = $(this).text();
            if(totalCarPrice!==undefined && totalCarPrice!==''){
                html += "￥"+totalCarPrice;
            }
            $(this).parent().html(html);
        });

        //转换门票、保险、附加信息
        $(".ticketDetail,.totalTicketPrice,.insuranceDetail,.totalInsurancePrice,.extraDetail,.totalExtraPrice").each(function(){
            var html = '';
            var value = $(this).val();
            var name = $(this).attr("name");
            if(value!==undefined && value!==''){
                if(name=='ticketPrice' || name=='extraPrice' || name=='insurancePrice'){
                    html += "￥"+value;
                }else{
                    html += value;
                }
            }else{
                html += "/";
            }
            $(this).parent().html(html);
        });

        //转换合价
        $("#totalPrice,#count_airportPrice,#count_hotelPrice,#count_drivePrice,#count_carPrice,#count_ticketPrice,#count_insurancePrice,#count_extraPrice").each(function(){
            var html = '';
            var value = $(this).text();
            if(value!==undefined && value!==''){
                html += "￥"+value;
            }else{
                html += "/";
            }
            $(this).parent().html(html);
        });


        //删除设置司导返程
        $(".setReturnJourney").each(function(){
            $(this).remove();
        });


        return true;
    }

    //导出Excel
    //jQuery HTML导出Excel文件(兼容IE及所有浏览器)
    $("#exportExcel").click(function(){
        transInput();
        var filename = $('#name').val();
        filename = filename+"*报价详情";

        var isMac = /macintosh|mac os x/i.test(navigator.userAgent);
        if(isMac){
            new Table2Excel('#summaryPricingTable').export(filename);
        }else{
            $("#summaryPricingTable").table2excel({
                name: "Excel Document Name.xls",
                filename: filename,
                fileext: ".xls"
            });
        }

        setTimeout(function(){
            window.location.reload();
        },1000);

        return false;
    });
</script>
<script src="__PUBLIC__/drag/Sortable.js"></script>
<script>
    $('.dragsort_div').each(function () {
        schedule_id = $(this).parent().find('.schedule_id').val();
        schedule_id = schedule_id+"_did";
        new Sortable( document.getElementById(schedule_id), {
            group: 'shared',
            animation: 350,
            draggable: ".a_div",
            handle: ".radius_div",
            scroll:true,
            forceFallback: true,
            onEnd:function (evt) {
                var active_id = $("#"+evt.item.id).find(".active_id").attr("value");
                var from_schedule_id = $("#"+evt.from.id).parent().parent().find(".schedule_id").attr("value");
                var to_schedule_id = $("#"+evt.to.id).parent().parent().find(".schedule_id").attr("value");
                var to_data_day = $("#"+evt.to.id).parent().parent().find(".schedule_id").attr("data-day");

                var active_id_list = '';
                var childNodes = evt.to.childNodes;
                for(var i=0;i<childNodes.length;i++){
                    var id = childNodes[i].id;
                    if(id!==undefined){
                        id = id.substring(0,id.length-4);
                        active_id_list = active_id_list+","+id;
                    }
                }

                console.log(active_id_list);

                $.ajax({
                    url:"{:url('/admin/product/changeActiveDay')}",
                    data:{active_id:active_id,schedule_id:to_schedule_id,active_id_list:active_id_list},
                    type:'post',
                    async: false,
                    success:function(res) {
                        if(res.code==1){
                            //当拖拽到不同day时
                            if(from_schedule_id!==to_schedule_id){
                                $("#"+evt.item.id).find(".active_id").attr("data-sid",to_schedule_id);
                                $("#"+evt.item.id).find(".active_id").attr("data-day",to_data_day);
                                $("#"+evt.item.id).find(".activeSelect_slt").attr("data-sid",to_schedule_id);
                            }
                            var prev_id = res.data.prev_id;
                            var next_id = res.data.next_id;
                            if(prev_id>0){
                                getPointDistace(prev_id,from_schedule_id);
                            }
                            if(next_id>0){
                                getPointDistace(next_id,from_schedule_id);
                            }
                            getPointDistace(active_id,to_schedule_id);

                            allSortKeyNum();

                            //如果地图显示状态刷新地图
                            if(visibleMap){
                                //模拟点击显示地图
                                $("#li_"+to_schedule_id).find(".getDayMap").click();
                            }
                        }else{
                            console.log(res);
                            layer.msg("修改失败");
                            setTimeout(function(){
                                location.reload();
                            },1500);
                            return false;
                        }
                    }
                });

                return false;
            }
        });
    });

    $('.example2').each(function () {
        new Sortable( document.getElementById("seeupload1"), {
            group: 'shared',
            animation: 150,
            scroll:true,
            forceFallback: true,
            onEnd:function (evt) {
                var schedule_id = evt.to.id;
                var img = [];
                $("#"+schedule_id).find(".list-group-item").each(function(){
                    img.push($(this).find('img').attr('src'));
                });
                $('#upload-thumb1').val(img.join(','));
                return false;
            }
        });
    });
</script>
<script>
    $("#toSupplier").click(function(){
        var supplier_id = $("#supplier_id").val();
        if(supplier_id!=='999999' && supplier_id!=='1000000'){
            var url = "{$kbx_url}"+"/admin/supplier/"+supplier_id;
            window.open(url);
        }
        return false;
    });
    $(".addCustomerContent").click(function(){
        var html = '<div class="layui-container">' +
            '<div class="layui-row">' +
            '<div class="layui-col-md12">' +
            '<label for="">' +
            '<input placeholder="请输入标题" class="layui-input layui-input-inline" name="customer_title" style="width:20%"><a class="layui-btn layui-btn-sm layui-btn-danger deleteCustomerContent">删除</a></label>' +
            '<div class="layui-inline" style="width:100%;">' +
                '<textarea placeholder="请输入内容" class="layui-textarea box_textarea" name="customer_content"></textarea>' +
            '</div>' +
            '</div>' +
            '</div>' +
            '</div>';
        $(".customerContentDiv").append(html);
    })
    $(document).on('click','.deleteCustomerContent',function(){
        var index = $(this).attr('data-index');
        if(index=='' || index==undefined){
            $(this).parent().parent().parent().parent().remove();
            return false;
        }
        var tripid = $("input[name=tripid]").val();
        var loading = layer.load(2);
        $.post('{:url("admin/product/delCustomerContent")}',{id:tripid,index:index},function (res) {
            layer.msg(res.msg);
            layer.close(loading)
            if(res.code < 1){
                return false;
            }else{
                $(this).parent().parent().parent().parent().remove();
                setTimeout(function () {
                    window.location.reload();
                },1000)
            }
        },'json')
    })
    $(document).on('blur','.customerContentDiv .layui-container input[name=customer_title]',function(){
        var title = $(this).val();
        var content = $(this).parent().parent().find('textarea[name=customer_content]').val();
        if(title!='' && content!=''){
            //自动提交保存
            autoSaveCustomerContent()
        }
    })
    $(document).on('blur','.customerContentDiv .layui-container textarea[name=customer_content]',function(){
        var content = $(this).val();
        var title = $(this).parent().parent().find('input[name=customer_title]').val();
        if(title!='' && content!=''){
            //自动提交保存
            autoSaveCustomerContent()
        }
    })

    //启用保存提交 修改为自动提保存
    function autoSaveCustomerContent(){
        var contents = $(".customerContentDiv .layui-container");
        console.log(contents);
        var params = [];
        var missing = false;
        $.each(contents,function (i,v) {
            var title = $(v).find('input[name=customer_title]').val();
            var content = $(v).find('textarea[name=customer_content]').val();
            if(title=='' || content==''){
                return true;
            }
            params.push({title:title,content:content});
        })
        console.log(params);
        if(params.length < 1 || missing){
            layer.msg('请补充所有的标题和内容！');return false;
        }
        var tripid = $("input[name=tripid]").val();
        var loading = layer.load(2);
        $.post('{:url("admin/product/saveCustomerContent")}',{id:tripid,contents:params},function (res) {
            layer.msg(res.msg);
            layer.close(loading)
            if(res.code < 1){
                return false;
            }else{
                setTimeout(function () {
                    window.location.reload();
                },1000)
            }
        },'json')
    }
</script>
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js?1.01"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js?1.01"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    {if (!$textPlan || !$isOpenTextPlan ) && !$FeaturedProduct}
    var ue = UE.getEditor('poi_content',{
        initialFrameHeight: 100,
        initialFrameWidth: 500,
        toolbars:[
            [ 'source', 'undo', 'redo'],
            ['bold', 'italic', 'underline', 'fontborder', 'strikethrough','removeformat']
        ]
    });

    var ue1 = UE.getEditor('content',{
        initialFrameHeight: 100,
        initialFrameWidth: 500,
        toolbars:[
            [ 'source'],
            ['bold', 'italic', 'underline', 'fontborder', 'strikethrough','removeformat']
        ]
    });
    var ue2 = UE.getEditor('newpoi_content',{
        initialFrameHeight: 100,
        initialFrameWidth: 400,
        zIndex:99,
        toolbars:[
            [ 'source'],
            ['bold', 'italic', 'underline', 'fontborder', 'strikethrough','removeformat']
        ]
    });
    {/if}
</script>
<!--售价日历-->
<script type="text/javascript">
    var moreTimeList = [];
    layui.use(['layer', 'element', 'form', 'laydate'], function() {
        //套餐获取
        var specsurl = '/admin/product/werk';
        //规格获取
        var posurl = '/admin/product/pos';
        //获取数据
        var starttime = "{$trip.sale_starttime}";
        var endtime = "{$trip.sale_endtime}";
        var personprice = {};
        var id = {$tripid};
        var list = {$dailyPriceData};
        var layer = layui.layer,
            element = layui.element,
            form = layui.form,
            laydate = layui.laydate;

        //重新渲染所有的日期控件
        function renderDateTimeWidget(){
            //重新渲染时间控件
            $('.x').each(function() {
                laydate.render({
                    elem: this //指定元素
                    ,trigger:'click'
                });
            });
        }
        renderDateTimeWidget();

        //获取产品全部日期价格集合
        function getPersonPrice(){
            $.ajax({
                url:"/admin/product/getPrice",
                type:"POST",
                dataType:'json',
                async:false,
                data:{id:id,sdate:starttime,edate:endtime},
                success:function (data) {
                    personprice = data.data;
                }
            })
        }
        getPersonPrice();
        {empty name="$trip.base_price_mode"}
        //初始化
        //1-1   获取并渲染产品套餐
        function showSpecsData(){
            $('.Spec').html(''); //清空容器
            var id = $('#product_id').val(); //获取产品id
            var starttime = $('#starttime').val(); //获取开始时间
            var endtime = $('#endtime').val(); //获取结束时间
            if(starttime.length <= 0) {
                layer.msg('开始时间不能为空');
                return false;
            }
            if(endtime.length <= 0) {
                layer.msg('结束时间不能为空');
                return false;
            }

            //开始时间转化时间戳
            var k = parseInt(new Date(starttime + ' 00:00:00').getTime());
            //结束时间转化时间戳
            var j = parseInt(new Date(endtime + ' 23:59:59').getTime());
            //获取当前时间戳
            var d = parseInt(new Date().getTime());
            if(j < k) {
                layer.msg('结束时间不能小于开始时间');
                return false;
            }

            //获取套餐
            $.ajax({
                url: specsurl,
                type: "post",
                dataType: "json",
                data: {
                    id: id
                },
                success: function(resData) {
                    if(resData.code==-1){
                        layer.msg("请先添加套餐");
                        return false;
                    }
                    resData = resData.data;
                    var packageHtml = ''; //套餐表头html
                    var priceHtml = ''; //价格内容html
                    $('.content').html('');
                    $.each(resData, function(i, v) {
                        var thisHtml = '';
                        var thisShowHtml = '';
                        if(i==0) {
                            thisHtml = 'class="layui-this"';
                            thisShowHtml = 'layui-show';
                        }else{
                            thisHtml = '';
                            thisShowHtml = '';
                        }
                        var package_id = v.id;
                        var normalSet = '<div date-pid="' + package_id + '" class="batch addBatch layui-btn layui-btn-sm layui-btn-normal" style="display: none;">普通成本</div>';
                        packageHtml += '<li id="top' + package_id + '"' + thisHtml + 'data-id="' + package_id + '">' + v.name + '</li>';
                        priceHtml += '<div class="layui-tab-item '+ thisShowHtml +'" id="yue' + package_id + '">' +
                            '<ul class="tab-ul">' +
                            '<li class="tab-ul-title specBatchBtn">' +
                            '<div date-pid="' + package_id + '" class="batch deleteBatch layui-btn layui-btn-sm layui-btn-danger">批量删除</div>' +
                            '<div date-pid="' + package_id + '" class="batch setBtn layui-btn layui-btn-sm layui-btn-default">设置成本</div>' +
                            normalSet +
                            '<div date-pid="' + package_id + '" class="batch addNewBatch layui-btn layui-btn-sm layui-btn-default" style="display: none;">包车成本</div>' +
                            '<div date-pid="' + package_id + '" class="batch setGoodsRate layui-btn layui-btn-sm layui-btn-warm" style="display: none;">成本系数</div>' +
                            '</li>' +
                            '</ul>' +
                            '<div class="layui-tab yue_div">' +
                            '<ul class="layui-tab-title" id="yue">' +
                            '</ul>' +
                            '<div class="layui-tab-content tas" id="tas' + package_id + '">' +
                            '</div>' +
                            '</div>' +
                            '<div class="layui-form-item ">' +
                            '</div>' +
                            '</div>' +
                            '</div>';
                        $('.Spec').html(packageHtml);
                        $('.content').html(priceHtml);
                    });
                    addhtm(starttime,endtime,resData);
                },
                error: function(jqXHR) {
                    console.log(jqXHR);
                }
            });
        }
        $(document).ready(function(){
            showSpecsData();
        });
        {/empty}
        //2-1       渲染价格日历、规格
        function addhtm(starttime,endtime,resData) {
            var package_id = resData[0].id;
            $.ajax({
                url: posurl,
                type: "post",
                dataType: "json",
                data: {
                    'package_id': package_id
                },
                success: function(data) {
                    yue(starttime, endtime, package_id, data);
                },
                error: function(jqXHR) {
                    console.log(jqXHR);
                }
            });
        }
        //2-2       获取区间内的月份
        function yue(starttime, endtime, package_id, data) {
            var da = getMonthAll(starttime, endtime);
            var month = '';
            $('#tas' + package_id).html('');
            for(var i = 0; i < da.length; i++) {
                var year = da[i].split('-');
                if(i == 0) {
                    month += '<li class="layui-this" lay-id="' + i + '">' + year[0] + '年' + year[1] + '月</li>';
                } else {
                    month += '<li  lay-id="' + i + '">' + year[0] + '年' + year[1] + '月</li>';
                }
                var tasHtml = datetime(da[i], i, data, package_id, starttime, endtime);
                $('#tas' + package_id).append(tasHtml);
                //高亮第一个时间
                $(".ri:first").click();
            }
            $('#yue' + package_id + ' #yue').html('');
            $('#yue' + package_id + ' #yue').prepend(month);
        }
        //2-2-1     查询时间维度里的所有月份
        function getMonthAll(starttime, endtime) {
            var d1 = starttime;
            var d2 = endtime;
            var dateArry = new Array();
            var s1 = d1.split("-");
            var s2 = d2.split("-");
            var mCount = 0;
            if(parseInt(s1[0]) < parseInt(s2[0])) {
                mCount = (parseInt(s2[0]) - parseInt(s1[0])) * 12 + parseInt(s2[1]) - parseInt(s1[1]) + 1;
            } else {
                mCount = parseInt(s2[1]) - parseInt(s1[1]) + 1;
            }
            if(mCount > 0) {
                var startM = parseInt(s1[1]);
                var startY = parseInt(s1[0]);
                for(var i = 0; i < mCount; i++) {
                    if(startM < 12) {
                        dateArry[i] = startY + "-" + (startM > 9 ? startM : "0" + startM);
                        startM += 1;
                    } else {
                        dateArry[i] = startY + "-" + (startM > 9 ? startM : "0" + startM);
                        startM = 1;
                        startY += 1;
                    }
                }
            }
            return dateArry;
        }
        //2-2-2     渲染日历
        function datetime(up, d, data, package_id, starttime, endtime) {
            starttime = starttime.split("-");
            endtime = endtime.split("-");
            up = up.split("-");
            var da = new Date(up[0], up[1], 0);
            //获取每月有多少天
            var day = da.getDate(); //获取当前月有多少天
            da.setDate(1);
            var we = da.getDay(); //获取当前月的第一天是星期几
            var a = 0;
            var str = '';
            var tr = '';
            var tab = ''; ///每一天的tab
            if(d == 0) {
                tr += '<div class="layui-tab-item layui-show">';
            } else {
                tr += '<div class="layui-tab-item">';
            }
            tr += "<div class='layui-col-md6'>";
            tr += '<table class="layui-table">' +
                '<div class="titl">' + up[0] + '年' + up[1] +'月</div>'+
                '<thead>' +
                '<tr class="week-title">' +
                '<td>星期日</td>' +
                '<td>星期一</td>' +
                '<td>星期二</td>' +
                '<td>星期三</td>' +
                '<td>星期四</td>' +
                '<td>星期五</td>' +
                '<td>星期六</td>' +
                '</tr>' +
                '</thead>' +
                '<tbody class="tian">';

            for(var i = 1; i <= day + we; i++) {
                a++;
                if(i > we) {
                    //按时间段渲染日历
                    var light = '';
                    var firstPrice = '';
                    var day_price_str = "";
                    var u = i - we;
                    var str_class = up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '">' + (u > 9 ? u : '0' + u);
                    var str_day = up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u);
                    if(str_day+','+package_id in personprice){
                        light = 'light_star show';
                        var day_index = str_day+','+package_id;
                        firstPrice = personprice[day_index][0]['price'] || "";
                    }
                    if(firstPrice!=""){
                        day_price_str = '<div class="day_price"><p style="width:80%;margin:0 auto;border-top:1px solid #ddd">'+ product_currency + firstPrice+'</p></div>';
                    }else{
                        day_price_str = '<div class="day_price_no"></div>';
                    }
                    if(u < starttime[2] && up[0] == starttime[0] && up[1] == starttime[1] || u > endtime[2] && up[0] == endtime[0] && up[1] == endtime[1]) {
                        str += '<td>' +
                            '<div class="ri-w '+light+'" date-specs="' + package_id + '" date-ri="' + str_class +'</div>' + day_price_str +
                            '</td>';
                    } else {
                        str += '<td>' +
                            '<div class="ri '+light+'" date-specs="' + package_id + '" date-ri="' + str_class +'</div>' + day_price_str +
                            '</td>';
                    }
                } else {
                    str += '<td></td>';
                }
                if(a == 7 || i == day + we) {
                    tr += '<tr>' + str + '</tr>';
                    str = '';
                    a = 0;
                }
                if(u === undefined) {

                } else {
                    if(u < starttime[2] && up[0] == starttime[0] && up[1] == starttime[1] || u > endtime[2] && up[0] == endtime[0] && up[1] == endtime[1]) {

                    } else {
                        var time = up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u);
                        tab += '<div class="person_off " id="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '" style="display: none;">' +
                            '<table class="layui-table">';
                        tab += '<thead><tr><th>名称</th><th>价格</th><th>数量</th><th>最低下单</th><th>最小增长</th></tr></thead>';
                        tab += '<tbody>';

                        //循环人群
                        //默认使用套餐数据填充 改用真实数据填充 2019-03-19
                        var oldperson = list[time+","+package_id];
                        if(oldperson!==undefined && oldperson!==null){
                            data = oldperson;
                        }else if(time+','+package_id in personprice){
                            data = personprice[time+","+package_id];
                        }
                        for(var j = 0; j < data.length; j++) {
                            var dayTitle = up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u);
                            tab += '<tr date-trd="' + dayTitle + '" date-person="' + data[j].person_id + '" >' +
                                '<td><input readonly type="text" name="person_name" date-aid="' + data[j].id + '" date-rq="' + dayTitle + '" class="layui-input input_div" placeholder="名称" value="' + data[j].name + '" /></td>' +
                                '<td><input type="number" autocomplete="off" name="person_price" date-dayid="' + data[j].id + '" date-rq="' + dayTitle + '" class="layui-input person_price_input input_div" placeholder="价格" value="' + data[j].price + '" /></td>' +
                                '<td><input readonly type="number" name="person_num" date-aid="' + data[j].id + '" date-rq="' + dayTitle + '"  class="layui-input input_div" placeholder="数量" value="' + data[j].num + '" />' +
                                '</td>' +
                                '<td><input readonly type="number" name="minorder_num" date-aid="' + data[j].id + '" date-rq="' + dayTitle + '"  class="layui-input input_div" placeholder="最低下单数" value="' + data[j].minorder_num + '" /></td>' +
                                '<td><input readonly type="number" name="inc_order_num" date-aid="' + data[j].id + '" date-rq="' + dayTitle + '"  class="layui-input input_div" placeholder="最小增长数" value="' + data[j].inc_order_num + '" /></td>';
                            tab += '</tr>';
                        }
                        tab +=
                            '</tbody>' +
                            '</table>' +'<a class="layui-btn layui-btn-sm layui-btn-normal modifySingleDayPrice">保存</a>' +
                            '</div>';
                    }
                }
            }

            tr += '</tbody>' +
                '</table>' +
                '</div>' +
                '<div class="layui-col-md1">&nbsp</div>' +
                '<div class="layui-col-md5 tabto">' + tab + '</div>' +
                '</div>';
            return tr;
        }

        //日历点击展示当日规格&价格
        function clickOneday(_that,type){
            $('.ri').removeClass('bj');
            $('.day_price').removeClass('bj');
            _that.addClass('bj');
            var ri;
            var specs;
            if(type=='date'){
                ri = _that.attr('date-ri');
                specs = _that.attr('date-specs');
                _that.next().addClass('bj')
            }else{
                ri = _that.prev().attr('date-ri');
                specs = _that.prev().attr('date-specs');
                _that.prev().addClass('bj')
            }
            $('#yue' + specs + ' #' + ri).siblings().hide();
            $('#yue' + specs + ' #' + ri).show();
            //点击时间弹框 取消自20190319-bywtt
            layer.msg(ri + '号', {
                time: 700
            });
        }
        $(document).on('click', '.ri', function() {
            if($(this).hasClass('show')){
                clickOneday($(this),'date')
            }
        });
        $(document).on('click', '.day_price', function() {
            if($(this).prev().hasClass('show')){
                clickOneday($(this),'price')
            }
        });

        //切换套餐
        element.on('tab(package)', function() {
            var starttime = $('#starttime').val(); //获取开始时间
            var endtime = $('#endtime').val(); //获取结束时间
            var package_id = this.getAttribute('data-id'); //获取套餐id
            if($('#yue' + package_id + ' #yue').is(":empty")) {
                $.ajax({
                    url: posurl,
                    type: "post",
                    dataType: "json",
                    data: {'package_id': package_id},
                    success: function(data) {
                        yue(starttime, endtime, package_id, data);
                    },
                    error: function(jqXHR) {
                        console.log(jqXHR);
                    }
                });
            }
        });

        $(document).on('click', '.setBtn', function(){
            var package_id = $(this).attr("date-pid");
            layer.confirm('请选择设置自营包车或者地接社？',{
                title : '选择产品价格类型',
                btn : ['自营包车','地接社'],
                btn1:function(){
                    layer.confirm('包车产品价格配置',{
                        title : '设置车型、酒店、门票',
                        btn : ['设置价格','设置价格系数'],
                        btn1:function(){
                            addNewBatch(package_id);
                        },
                        btn2:function(){
                            setGoodsRate();
                        }
                    });
                },
                btn2:function(){
                    layer.confirm('常规设置套餐规格',{
                        title : '自由设置',
                        btn : ['设置价格','设置套餐'],
                        btn1:function(){
                            addBatch();
                        },
                        btn2:function(){
                            addPackage();
                        }
                    });
                }
            });
            return false;
        });

        /*********【普通成本】配置弹窗   click打开*************/
        //【普通成本】
        function addBatch() {
            var package_id = $(".addBatch").attr('date-pid');
            //添加时需要展示快照信息
            $("#specsPriceSnap").show();
            $.post(posurl, {
                'package_id': package_id
            }, function(data) {
                renderSelectTimeForm();
                form.render();
                renderPersonList(data);
            });
            //显示添加时间的按钮 不允许修改
            $(".addMoreTime").show();
            moreTimeList = [];
            $("#moreTimeArr").children().remove();
            //打开一个弹窗 点击保存触发事件
            layer.open({
                type: 1,
                area: ['80%', '80%'],
                btn: ['保存', '取消'],
                content: $('#setPriceShade'),
                yes: function(index, layero) {
                    var pro_start_day = $('#starttime').val(); //获取开始时间
                    var pro_end_day = $('#endtime').val(); //获取结束时间
                    var save_start_day = $("input[name=t-starttime]").val();
                    var save_end_day = $("input[name=t-endtime]").val();
                    var pro_start_time = parseInt(new Date(pro_start_day + ' 00:00:00').getTime());
                    var save_start_time = parseInt(new Date(save_start_day + ' 00:00:00').getTime());
                    var pro_end_time = parseInt(new Date(pro_end_day + ' 23:59:59').getTime());
                    var save_end_time = parseInt(new Date(save_end_day + ' 23:59:59').getTime());
                    if(save_start_time < pro_start_time) {
                        layer.msg('时间段开始时间小于产品上架时间');
                        return false;
                    }
                    if(save_end_time > pro_end_time) {
                        layer.msg('时间段结束时间大于产品下架时间');
                        return false;
                    }
                    if(save_end_time < save_start_time) {
                        layer.msg('结束时间不能小于开始时间');
                        return false;
                    }
                    var time_type = $('input[name=time_type]:checked').val();
                    var month_value = $('input[name=month_value]:checked').val();
                    var time_value = [];
                    if(time_type==0 || time_type==3){
                        time_value = '';
                    }else if(time_type==1){
                        time_value = month_value;
                    }else{
                        var week_value = $("input[name=week]:checked");
                        if(week_value.length<1){
                            layer.msg("请选择日期类型");
                            return false;
                        }else{
                            $.each(week_value,function(i,v){
                                time_value.push($(v).val())
                            });
                            time_value = time_value.join(",");
                        }
                    }
                    //获取筛选的数据
                    var selectDays = getDaysByDates(save_start_day,save_end_day,time_type,time_value);
                    if(time_type==3){
                        selectDays = moreTimeList;
                    }
                    if(selectDays.length < 1){
                        layer.msg("您选择的时间段中没有时间被选择");
                        return false;
                    }
                    var package_id = $('input[name=select_package_id]:checked').val();
                    if(package_id=='' || package_id==undefined){
                        layer.msg("您选择套餐");
                        return false;
                    }
                    //保存数据
                    savePackageData(package_id,selectDays,moreTimeList);
                }
            });
        }

        //【设置套餐】
        function addPackage() {
            var product_id = $("#product_id").val();
            var url = "/admin/product/addPackage?id="+product_id;
            //打开一个弹窗 点击保存触发事件
            layer.open({
                type:2,
                content:url,
                area: ['80%', '80%'],
                end:function(){
                    location.reload();
                }
            });
        }

        //【批量删除】
        $(document).on('click', '.deleteBatch', function() {
            //删除时不需要展示快照信息
            $("#specsPriceSnap").hide();
            var package_id = $(this).attr('date-pid');
            $.post(posurl, {'package_id': package_id}, function(da) {
                renderSelectTimeForm();
                form.render();
                renderPersonList(da);
            });
            //显示添加时间的按钮 允许修改
            $(".addMoreTime").show();
            moreTimeList = [];
            $("#moreTimeArr").children().remove()
            //打开一个弹窗 点击保存触发事件
            layer.open({
                type: 1,
                area: ['1000px', '70%'],
                btn: ['删除', '取消'],
                content: $('#setPriceShade'),
                yes: function(index, layero) {
                    var pro_start_day = $('#starttime').val(); //获取开始时间
                    var pro_end_day = $('#endtime').val(); //获取结束时间
                    var save_start_day = $("input[name=t-starttime]").val();
                    var save_end_day = $("input[name=t-endtime]").val();
                    var pro_start_time = parseInt(new Date(pro_start_day + ' 00:00:00').getTime());
                    var save_start_time = parseInt(new Date(save_start_day + ' 00:00:00').getTime());
                    var pro_end_time = parseInt(new Date(pro_end_day + ' 23:59:59').getTime());
                    var save_end_time = parseInt(new Date(save_end_day + ' 23:59:59').getTime());
                    if(save_start_time < pro_start_time) {
                        layer.msg('时间段开始时间小于产品上架时间');
                        return false;
                    }
                    if(save_end_time > pro_end_time) {
                        layer.msg('时间段结束时间大于产品下架时间');
                        return false;
                    }
                    if(save_end_time < save_start_time) {
                        layer.msg('结束时间不能小于开始时间');
                        return false;
                    }
                    var time_type = $('input[name=time_type]:checked').val();
                    var month_value = $('input[name=month_value]:checked').val();
                    var time_value = [];
                    if(time_type==0 || time_type==3){
                        time_value = '';
                    }else if(time_type==1){
                        time_value = month_value;
                    }else{
                        var week_value = $("input[name=week]:checked");
                        if(week_value.length<1){
                            layer.msg("请选择日期类型");
                            return false;
                        }else{
                            $.each(week_value,function(i,v){
                                time_value.push($(v).val())
                            });
                            time_value = time_value.join(",");
                        }
                    }
                    //获取筛选的数据
                    var selectDays = getDaysByDates(save_start_day,save_end_day,time_type,time_value);
                    if(time_type==3){
                        selectDays = moreTimeList;
                    }
                    if(selectDays.length < 1){
                        layer.msg("您选择的时间段中没有时间被选择");
                        return false;
                    }
                    // 保存数据
                    packageDeleteData(package_id,selectDays,moreTimeList);
                }
            });
        });
        //修改单日的套餐价格
        $(document).on('click','.modifySingleDayPrice',function(){
            var priceTable = $(this).prev().find('.person_price_input');
            var postdata = [];
            var flag = true;
            $.each(priceTable,function(i,v){
                var id = $(v).attr('date-dayid');
                var price = $(v).val();
                if(price=="" || price<=0 || price==undefined){
                    flag = false;
                    return false;
                }else{
                    postdata.push({id:id,price:price});
                }
            });
            if(!flag){
                layer.msg("请填写所有的价格！");return false;
            }else{
                postdata = JSON.stringify(postdata);
                var product_id = $('#product_id').val(); //获取产品id
                $.post("/admin/product/setSingleDayPrice",{product_id:product_id,data:postdata},function(data){
                    layer.msg(data.msg);
                    if(data.code=='200'){
                        setTimeout(function(){
                            window.location.reload();
                        },1000)
                    }
                },'json')
            }
        });

        //【普通成本】弹窗中时间段选择渲染
        function renderSelectTimeForm(){
            $('#selectTimeForm').children().remove();
            var str = '<label class="layui-form-label">&nbsp;</label>\n' +
                '                        <div class="layui-input-block layui-col-xs6" style="margin: 0;">\n' +
                '                            <input type="radio" lay-filter="time_type" title="全部" checked name="time_type" value="0" />\n' +
                '                            <input type="radio" lay-filter="time_type" title="按单双日" name="time_type" value="1" />\n' +
                '                            <input type="radio" lay-filter="time_type" title="按星期" name="time_type" value="2" />\n' +
                '                        </div>\n' +
                '                        <div class="layui-input-block layui-col-xs8" id="single" style="margin-left: 130px;display: none;">\n' +
                '                            <input type="radio" lay-filter="month_value" title="每月单日" name="month_value" value="8" />\n' +
                '                            <input type="radio" lay-filter="month_value" title="每月双日" name="month_value" value="9" />\n' +
                '                        </div>\n' +
                '                        <div class="layui-input-block layui-col-xs8" id="week" style="margin-left: 130px;display: none;">\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周一" class="time_week" name="week" value="1" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周二" class="time_week" name="week" value="2" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周三" class="time_week" name="week" value="3" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周四" class="time_week" name="week" value="4" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周五" class="time_week" name="week" value="5" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周六" class="time_week" name="week" value="6" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周日" class="time_week" name="week" value="0" />\n' +
                '                        </div>\n';
            $('#selectTimeForm').append(str);
        }
        //【普通成本】弹窗中规格table渲染
        function renderPersonList(data){
            //渲染规格
            $('.batch_person').html('');
            var sr = '';
            $.each(data, function(i, v) {
                sr += '<tr date-id="' + v.person_id + '">' +
                    '<td><input readonly type="text" name="person_name" id="person_name" class="layui-input" placeholder="' + v.name + '" value="' + v.name + '"/>' +
                    '<input type="hidden" name="person_id" id="person_id" class="layui-input" value="' + v.id + '"/></td>' +
                    '<td><input type="text" name="person_price" id="person_price" class="layui-input" autocomplete="off" placeholder="' + v.name + '成本" value="" style="border:1px solid red"/></td>' +
                    '<td><input readonly type="text" name="person_num" id="person_num" class="layui-input" placeholder="库存" value="' + v.num + '" /></td>' +
                    '<td><input readonly type="text" name="minorder_num" id="minorder_num" class="layui-input" placeholder="最低下单数" value="' + v.minorder_num +'" /></td>' +
                    '<td><input readonly type="text" name="inc_order_num" id="inc_order_num" class="layui-input" placeholder="最小增长数" value="' + v.inc_order_num +'" /></td></tr>';
            });

            $('.batch_person').html(sr);
            form.render('select');
        }
        $(document).on('input','.batch_person input[name=person_price]',function(){
            if($(this).val()!==''){
                $(this).css('border','none');
            }else{
                $(this).css('border','1px solid red');
            }
        })
        //提交数据时组装日期价格数据
        function getDaysByDates(starttime,endtime,time_type,time_value){
            var dateArry = new Array();
            var s1 = starttime.split("-");
            var s2 = endtime.split("-");
            var monthCount = 0;
            if(parseInt(s1[0]) < parseInt(s2[0])) {
                monthCount = (parseInt(s2[0]) - parseInt(s1[0])) * 12 + parseInt(s2[1]) - parseInt(s1[1]) + 1;
            } else {
                monthCount = parseInt(s2[1]) - parseInt(s1[1]) + 1;
            }
            var stime= new Date(starttime+' 00:00:00').getTime()-1000;
            var etime= new Date(endtime+' 23:59:59').getTime();
            if(monthCount > 0) {
                var startM = parseInt(s1[1]);
                var startY = parseInt(s1[0]);
                for(var i = 0; i < monthCount; i++) {
                    var da = new Date(startY, startM, 0);
                    //获取每月有多少天
                    var day = da.getDate(); //获取当前月有多少天
                    for(j = 1; j <= day; j++) {
                        var the_day = startY + "-" + (startM > 9 ? startM : "0" + startM) + "-" + (j > 9 ? j : "0" + j);
                        var curtime = new Date(startY + '-' + startM + '-' + j + ' 00:00:00');
                        var curtime = curtime.getTime();
                        if(curtime < stime || curtime > etime){
                            continue;
                        }
                        if (time_type == 0) {
                            dateArry.push(the_day);
                        } else if(time_type ==1) {
                            //单日
                            if (j % 2 == 1 && time_value == '8') {
                                dateArry.push(the_day);
                            } else if (j % 2 == 0 && time_value == '9') {
                                //双日
                                dateArry.push(the_day);
                            }
                        }else if(time_type ==2){
                            //周
                            var value = time_value.split(",");
                            var w = new Date(startY + '-' + startM + '-' + j)
                            var the_week = w.getDay();
                            var index= value.indexOf(String(the_week));
                            if ( index > -1) {
                                dateArry.push(the_day);
                            }

                        }
                    }
                    if(startM<12){
                        startM += 1;
                    }else{
                        startM = 1;
                        startY += 1;
                    }
                }
            }
            return dateArry;
        }
        //【普通成本】提交数据
        function savePackageData(package_id,date,more_time){
            //记录数据
            var postData = {};
            //组装数组
            var specs = [];
            var personlist = $(".batch_person tr");
            var isMissingPrice = false;
            $.each(personlist,function(i,v){
                var spec = {};
                spec.id = $(v).find("input[name=person_id]").val();
                spec.price = $(v).find("input[name=person_price]").val();
                if(spec.price=='' || spec.price==undefined){
                    isMissingPrice = true;
                    layer.msg('请补充完所有的成本！');
                    return false;
                }
                specs.push(spec);
            });
            if(isMissingPrice) return false;
            postData.specs = specs;
            postData.date = date;
            //组装时间集合
            postData.package_id = package_id;
            postData.more_time = more_time;
            var param = JSON.stringify(postData);
            var shadowindex = layer.load(1);
            $.post("/admin/product/ajaxsetgoodsprice",{param},function(data){
                layer.close(shadowindex);
                layer.msg(data.msg);
                if(data.code==200){
                    setTimeout(function(){
                        //window.location.reload();
                    },1500);
                }
            },'json');
            return true;
        }
        //【批量删除】提交数据
        function packageDeleteData(package_id,date,more_time){
            var postData = {};
            postData.date = date;
            //组装时间集合
            postData.package_id = package_id;
            postData.more_time = more_time;
            var param = JSON.stringify(postData);
            var shadowindex = layer.load(1);
            $.post("/admin/product/delsetgoodsprice",{param},function(data){
                layer.close(shadowindex);
                layer.msg(data.msg);
                if(data.code==200){
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                }
            },'json');
            return true;
        }

        //点击日期类型 切换tab
        function changeTimeType(value){
            if(value==1){
                $("#single").show();
                $("#week").hide();
                $("#moreTimeForm").show();
            }else if(value==2){
                $("#single").hide();
                $("#week").show();
                $("#moreTimeForm").show();
            }else if(value==3){
                $("#single").hide();
                $("#week").hide();
                $("#moreTimeForm").show();
            }else{
                $("#single").hide();
                $("#week").hide();
                $("#moreTimeForm").hide();
            }
        }
        //弹框日期选择
        form.on('radio(time_type)', function(data) {
            var value = data.value;
            changeTimeType(value);
        });
        //弹层单选按钮
        form.on('radio(radio)', function(data) {
            if(data.value == 3) {
                $('#chx').css('display', 'block');
            } else {
                $('#chx').css('display', 'none');
            }
        });
        //切换套餐
        form.on('radio(change_package)',function(data){
            var package_id = data.value;
            console.log(package_id);
            $.post(posurl, {
                'package_id': package_id
            }, function(data) {
                renderPersonList(data);
            });
        })
        //【普通成本】弹窗中时间段
        //添加具体的天数
        $(".addMoreTime").click(function(){
            var currentTime = $("input[name=moreTime]").val();
            var t_starttime=$("input[name=t-starttime]").val();
            var t_endtime=$("input[name=t-endtime]").val();
            if(t_starttime=='' || t_endtime==''){
                layer.msg("请选择开始和结束时间");return false;
            }else if(currentTime=="" || currentTime==undefined){
                layer.msg("请选择时间");
            }else if($.inArray(currentTime,moreTimeList)>-1){
                layer.msg("请勿重复添加时间");
            }else if(currentTime<t_starttime || currentTime > t_endtime){
                layer.msg("请在开始和结束时间之间选择");
            }else{
                moreTimeList.push(currentTime);
                var str = '<a class="layui-btn layui-btn-sm layui-bg-cyan delMoreTime" data-id="'+currentTime+'" style="margin:8px;">'+currentTime+' <i class="layui-icon">&#x1006;</i></a>\n';
                $("#moreTimeArr").append(str);
            }
        });
        //删除具体的天数
        $(document).on('click','.delMoreTime',function(){
            var currentTime = $(this).attr('data-id');
            moreTimeList.splice($.inArray(currentTime,moreTimeList),1);
            $(this).remove();
        });



        /*********【成本系数】配置弹窗   click打开*************/
        //【成本系数】
        function setGoodsRate() {
            var product_id = $("#product_id").val();
            var url = "/admin/product/setvehicleinfo?id="+product_id;
            //打开一个弹窗 点击保存触发事件
            layer.open({
                type:2,
                content:url,
                area: ['80%', '80%'],
                end:function(){
                    location.reload();
                }
            });
        }


        /*********【包车成本】配置弹窗   click打开*************/
        //【包车成本】
        function addNewBatch(package_id){
            var product_id = $("#product_id").val();

            //show时间段选择
            renderSelectTimeFormNew();
            form.render();

            //获取酒店门票数据
            $.ajax({
                url:"/admin/product/getPriceSetData",
                type:"POST",
                dataType:'json',
                data:{product_id:product_id},
                success:function (res) {
                    if(res.code==1){
                        var hotel_data = res.data.product.hotel_price_json;
                        var currency = res.data.product.currency;//货币类型
                        var ticket_data = res.data.ticket;
                        var exchange_data = res.data.exchange;

                        $("#vehicle_rate").attr("value",res.data.product.vehicle_rate);
                        $("#hotel_rate").attr("value",res.data.product.hotel_rate);
                        $("#ticket_rate").attr("value",res.data.product.ticket_rate);
                        $("#extra_rate").attr("value",res.data.product.extra_rate);

                        $.each(exchange_data, function(i, v) {
                            if(v.currency_code=='USD'){
                                $("#USD_rate").attr("value",v.exchange_rate);
                            }else if(v.currency_code=='CAD'){
                                $("#CAD_rate").attr("value",v.exchange_rate);
                            }else if(v.currency_code=='JPY'){
                                $("#JPY_rate").attr("value",v.exchange_rate);
                            }
                        });

                        var hotel_html = '';
                        if(hotel_data!==null){
                            $.each(hotel_data, function(i, v) {
                                hotel_html += '<tr>' +
                                    '<th>'+v.cityName+'</th>' +
                                    '<th>'+v.levelName+'</th>' +
                                    '<th>'+v.days+'晚</th>' +
                                    '<th><div style="width:8%;float: left;line-height: 40px;">'+v.cost.currSymbol+'</div>' +
                                    '<div style="width:90%;float: left;">' +
                                    '<input type="hidden" class="days" value="'+v.days+'">' +
                                    '<input type="hidden" class="kbxCityId" value="'+v.kbxCityId+'">' +
                                    '<input type="hidden" class="currency" value="'+v.cost.currency+'">' +
                                    '<input type="hidden" class="hotelCostToPrice" value="">' +
                                    '<input type="number" class="layui-input hotelCost" placeholder="请填写成本" value="" style="margin-top:5px;">' +
                                    '</div>' +
                                    '</th>';
                                hotel_html += '</tr>';
                            });
                        }
                        hotel_html += '</tr><tr>' +
                            '<th>酒店总成本</th>' +
                            '<th colspan="4">' +
                            '<div style="width:5%;float: left;line-height: 50px;">￥</div>' +
                            '<div style="width:92%;float: left;">' +
                            '<input type="text" readonly class="layui-input" id="hotel_total_cost" value="0" style="margin-top:10px;">' +
                            '</div>' +
                            '</th>' +
                            '</tr>';
                        $("#hotel_body").html(hotel_html);

                        var total_cost = 0;
                        var USD_rate = $("#USD_rate").attr("value");
                        var CAD_rate = $("#CAD_rate").attr("value");
                        var JPY_rate = $("#JPY_rate").attr("value");
                        var ticket_html = '';
                        $.each(ticket_data, function(i, v) {
                            var currSymbol = 'CNY';
                            var cost = Number(v.cost_price);
                            var rate = 1;
                            $.each(exchange_data,function (exchange_i,exchange_v) {
                                if(exchange_v.currency_code==v.currency){
                                    rate = exchange_v.exchange_rate;
                                    currSymbol = v.currency;
                                    return false;
                                }
                            })
                                total_cost += cost*rate;

                            ticket_html += '<tr>' +
                                '<th><input type="hidden" class="ticket_id" value="'+v.id+'">'+v.poiname+' - '+v.name+'</th>' +
                                '<th>x1</th>' +
                                '<th>'+currSymbol+' '+v.cost_price+'</th>';
                            ticket_html += '</tr>';
                        });
                        //保留两位小数
                        total_cost = total_cost.toFixed(2);
                        ticket_html += '</tr><tr>' +
                            '<th>门票总成本</th>' +
                            '<th colspan="2">' +
                            '<div style="width:5%;float: left;line-height: 50px;">￥</div>' +
                            '<div style="width:92%;float: left;">' +
                            '<input type="text" readonly class="layui-input" id="ticket_total_cost" value="'+total_cost+'" style="margin-top:10px;">' +
                            '</div>' +
                            '</th>' +
                            '</tr>';
                        $("#ticket_body").html(ticket_html);
                        //额外价格
                        var extra_fee = res.data.product.extra_fee || "";
                        var extra_fee_desc = res.data.product.extra_fee_desc || "";
                        var extra_fee_arr = extra_fee.split(",");
                        var extra_fee_desc_arr = extra_fee_desc.split("|");
                        var extra_fee_total = 0;
                        var extra_currency = 1;
                        $.each(exchange_data, function(i, v) {
                            if(v.currency_code==currency){
                                extra_currency = parseFloat(v.exchange_rate);
                                return false;
                            }
                        });
                        $("#extraNode tr").each(function (i,v) {
                            var extra_fee_v = extra_fee_arr[i] || 0;
                            var extra_fee_cny_v = 0;
                            var extra_fee_desc_v = extra_fee_desc_arr[i] || '';
                            if(i<$("#extraNode tr").length-1){
                                extra_fee_v = parseInt(extra_fee_v);
                                extra_fee_cny_v = (extra_fee_v*extra_currency).toFixed(2);
                                $(v).find('input[name=extra_fee_local]').val(extra_fee_v);
                                $(v).find('input[name=extra_fee_cny]').val(extra_fee_cny_v);
                                $(v).find('input[name=extra_fee_desc]').val(extra_fee_desc_v);
                                extra_fee_total += parseFloat(extra_fee_cny_v);
                            }
                        });
                        $("#extra_fee_total").val(extra_fee_total.toFixed(2));
                        setCarPrice();
                    }
                }
            });

            //打开一个弹窗 点击保存触发事件
            layer.open({
                type: 1,
                area: ['80%', '80%'],
                scrollbar: false,
                btn: ['保存', '取消'],
                content: $('#setNewPriceShade'),
                yes: function(index, layero) {
                    var time_type = $('input[name=time_type]:checked').val();
                    var month_value = $('input[name=month_value]:checked').val();
                    var time_value = [];
                    if(time_type==0 || time_type==3){
                        time_value = '';
                    }else if(time_type==1){
                        time_value = month_value;
                    }else{
                        var week_value = $("input[name=week]:checked");
                        if(week_value.length<1){
                            layer.msg("请选择日期类型");
                            return false;
                        }else{
                            $.each(week_value,function(i,v){
                                time_value.push($(v).val())
                            });
                            time_value = time_value.join(",");
                        }
                    }
                    //获取筛选的数据
                    var selectDays = [];
                    $('#selectTimeArr a').each(function(i,v){
                        var date_str = $(v).attr('data-id');
                        var date_arr = date_str.split(' - ');
                        var log_start_day = date_arr[0] || "";
                        var log_end_day = date_arr[1] || "";
                        console.log(log_start_day,log_end_day);

                        var daysArr = getDaysByDates(log_start_day,log_end_day,time_type,time_value);
                        console.log(daysArr);
                        $.each(daysArr,function (ii,vv) {
                            if($.inArray(vv,selectDays) < 0){
                                selectDays.push(vv);
                            }
                      })
                    })
                    if(time_type==3){
                        selectDays = moreTimeList;
                    }
                    if(selectDays.length < 1){
                        layer.msg("您选择的时间段中没有时间被选择");
                        return false;
                    }else{
                        selectDays.sort();
                    }


                    
                    var f_cost = $("#5_cost").val();
                    var s_cost = $("#7_cost").val();
                    var t_cost = $("#12_cost").val();

                    if(f_cost>0 && s_cost>0){

                    }else{
                        layer.msg("请填写包车价格！");
                        return false;
                    }

                    var more_btn = $("#more_btn").attr("data-id");
                    if(more_btn==1){
                        var error_flag = 0;
                        $(".hotelCost").each(function(){
                            var hotelCost_val = $(this).val();
                            if(hotelCost_val>0){

                            }else{
                                error_flag = 1;
                                return false;
                            }
                        });
                        if(error_flag>0){
                            layer.msg("请填写酒店价格！");
                            return false;
                        }
                    }else{
                        if(t_cost>0){

                        }else{
                            layer.msg("请填写包车价格！");
                            return false;
                        }
                    }

                    //保存数据
                    saveVehiclePackageData(package_id,selectDays,moreTimeList);
                }
            });
        }

        //【包车成本】弹窗中时间段选择渲染
        function renderSelectTimeFormNew(){
            $('#selectNewTimeForm').children().remove();
            var str = '<label class="layui-form-label">&nbsp;</label>\n' +
                '                        <div class="layui-input-block layui-col-xs6" style="margin: 0;">\n' +
                '                            <input type="radio" lay-filter="time_type" title="全部" checked name="time_type" value="0" />\n' +
                '                            <input type="radio" lay-filter="time_type" title="按单双日" name="time_type" value="1" />\n' +
                '                            <input type="radio" lay-filter="time_type" title="按星期" name="time_type" value="2" />\n' +
                '                        </div>\n' +
                '                        <div class="layui-input-block layui-col-xs8" id="single" style="margin:0 0 0 130px;display: none;">\n' +
                '                            <input type="radio" lay-filter="month_value" title="每月单日" name="month_value" value="8" />\n' +
                '                            <input type="radio" lay-filter="month_value" title="每月双日" name="month_value" value="9" />\n' +
                '                        </div>\n' +
                '                        <div class="layui-input-block layui-col-xs8" id="week" style="margin-left: 130px;display: none;">\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周一" class="time_week" name="week" value="1" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周二" class="time_week" name="week" value="2" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周三" class="time_week" name="week" value="3" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周四" class="time_week" name="week" value="4" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周五" class="time_week" name="week" value="5" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周六" class="time_week" name="week" value="6" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周日" class="time_week" name="week" value="0" />\n' +
                '                        </div>\n';
            //增加额外的时间
            $('#selectNewTimeForm').append(str);
        }

        //实时计算
        //酒店成本变动
        function countHotelCost(){
            var USD_rate = $("#USD_rate").attr("value");
            var CAD_rate = $("#CAD_rate").attr("value");
            var JPY_rate = $("#JPY_rate").attr("value");
            var total_cost = 0;
            $(".hotelCost").each(function(){
                var cost = $(this).val();
                if(cost==undefined || cost<=0){
                    return false;
                }
                var currency = $(this).parent().find(".currency").val();
                var days = $(this).parent().find(".days").val();
                days = parseInt(days);
                var final_cost = Number(cost);
                var rate = 1;
                //获取汇率
                $.each(exchangeList,function (exchange_i,exchange_v) {
                    if(exchange_v['currency_code']==currency){
                        rate = exchange_v['exchange_rate'];
                    }
                })
                final_cost = final_cost*days*rate;
                total_cost += final_cost;

                var hotel_rate = $("#hotel_rate").attr("value");
                hotel_rate = parseFloat(hotel_rate);
                var hotelCostToPrice = final_cost*hotel_rate;
                hotelCostToPrice = Math.ceil(hotelCostToPrice*100)/100;
                $(this).parent().find(".hotelCostToPrice").attr("value",hotelCostToPrice);
            });

            total_cost = Math.ceil(total_cost*100)/100;
            $("#hotel_total_cost").attr("value",total_cost);
        }
        $(document).on("input propertychange",'.hotelCost',function(){
            countHotelCost();
            createSpecs();
        });
        //包车成本变动
        $(document).on("input propertychange",'#5_cost_currency,#7_cost_currency,#12_cost_currency',function(){
            var exchangeNum = $("#exchangeNum").attr("value");
            exchangeNum = parseFloat(exchangeNum);
            var id = $(this).attr("id");
            var value = $(this).val();
            value = Number(value);
            var cny_value = value*exchangeNum;
            cny_value = Math.round(cny_value*100)/100;

            var cost_input;
            if(id=="5_cost_currency"){
                cost_input = $("#5_cost");
            }else if(id=="7_cost_currency"){
                cost_input = $("#7_cost");
            }else if(id=="12_cost_currency"){
                cost_input = $("#12_cost");
            }
            cost_input.attr("value",cny_value);

            createSpecs();
        });
        //根据成本   展示自动生成的规格价格
        function createSpecs(){
            var f_cost = $("#5_cost").val();
            var s_cost = $("#7_cost").val();
            var t_cost = $("#12_cost").val();
            f_cost = Number(f_cost);
            s_cost = Number(s_cost);
            t_cost = Number(t_cost);
            //全部取整
            // f_cost = Math.ceil(f_cost);
            // s_cost = Math.ceil(s_cost);
            // t_cost = Math.ceil(t_cost);
            var hotel_total_cost = $("#hotel_total_cost").val();
            var ticket_total_cost = $("#ticket_total_cost").val();
            var extra_total_cost = $("#extra_fee_total").val();
            var vehicle_rate = $("#vehicle_rate").attr("value");
            var hotel_rate = $("#hotel_rate").attr("value");
            var ticket_rate = $("#ticket_rate").attr("value");
            var extra_rate = $("#extra_rate").attr("value");

            //存储成本
            var save_vehicle_cost = 0;
            var hotel_vehicle_cost = 0;
            var ticket_vehicle_cost = 0;
            var extra_vehicle_cost = 0;

            vehicle_rate = parseFloat(vehicle_rate);
            hotel_rate = parseFloat(hotel_rate);
            ticket_rate = parseFloat(ticket_rate);
            extra_rate = parseFloat(extra_rate);
            //用车价格
            var f_cost_sale = f_cost>0 ? f_cost*vehicle_rate : 0;
            var s_cost_sale = f_cost>0 ? s_cost*vehicle_rate : 0;
            var t_cost_sale = f_cost>0 ? t_cost*vehicle_rate : 0;
            f_cost_sale = Math.ceil(f_cost_sale*100)/100;
            s_cost_sale = Math.ceil(s_cost_sale*100)/100;
            t_cost_sale = Math.ceil(t_cost_sale*100)/100;

            hotel_total_cost = Number(hotel_total_cost);
            hotel_total_cost = hotel_total_cost>0 ? hotel_total_cost : 0;
            var hotel_price = hotel_total_cost>0 ? hotel_total_cost*hotel_rate : 0;
            ticket_total_cost = Number(ticket_total_cost);
            ticket_total_cost = ticket_total_cost>0 ? ticket_total_cost : 0;
            var ticket_price = ticket_total_cost>0 ? ticket_total_cost*ticket_rate : 0;
            extra_total_cost = Number(extra_total_cost);
            extra_total_cost = extra_total_cost>0 ? extra_total_cost : 0;
            var extra_price = extra_total_cost>0 ? extra_total_cost*extra_rate : 0;

            hotel_price = Math.ceil(hotel_price*100)/100;
            ticket_price = Math.ceil(ticket_price*100)/100;
            extra_price = Math.ceil(extra_price*100)/100;

            hotel_vehicle_cost = hotel_total_cost>0 ? Math.ceil(hotel_total_cost*100)/100 : 0;
            ticket_vehicle_cost = ticket_total_cost>0 ? Math.ceil(ticket_total_cost*100)/100 : 0;
            extra_vehicle_cost = extra_total_cost>0 ? Math.ceil(extra_total_cost*100)/100 : 0;

            var more_btn = $("#more_btn").attr("data-id");
            var html = '';
            var head_html = '';

            if(more_btn==1) {
                //包含酒店&门票
                head_html = '<tr><th>出行类型</th><th>车型</th><th style="width:10%;">最低下单数</th><th style="width:10%;">最小增长数</th><th>【 包车*辆*<span class="redsp">利率</span> + 酒店*间*<span class="redsp">利率</span> + 门票*人*<span class="redsp">利率</span> + 额外费用*<span class="redsp">利率</span>】 / 人数</th><th>售卖单价</th></tr>';
                for(var i=1;i<=6;i++){
                    var vehicle_price = 0;
                    var other_price = 0;
                    var text = '【 (';
                    var carType = '';
                    var carTypeCode = 1;
                    if(i<=3){
                        vehicle_price = f_cost_sale;
                        save_vehicle_cost = f_cost;
                        carType = '5座';
                        carTypeCode = 1;
                        text += "<span class='boldsp'>"+f_cost + "</span> x <span class='boldsp'>1</span>辆" + " x <span class='redsp'>" +vehicle_rate;
                    }else if(3<i<=6){
                        vehicle_price = s_cost_sale;
                        save_vehicle_cost = s_cost;
                        carType = '7座';
                        carTypeCode = 10;
                        text += "<span class='boldsp'>"+s_cost + "</span> x <span class='boldsp'>1</span>辆" + " x <span class='redsp'>" +vehicle_rate;
                    }else{
                        vehicle_price = t_cost_sale;
                        save_vehicle_cost = t_cost;
                        carType = '12座';
                        carTypeCode = 20;
                        text += "<span class='boldsp'>"+t_cost + "</span> x <span class='boldsp'>1</span>辆" + " x <span class='redsp'>" +vehicle_rate;
                    }
                    text += "</span>) + (<span class='boldsp'>";
                    if(i<=2){
                        other_price = hotel_price + ticket_price*i;
                        text += hotel_total_cost + "</span> x <span class='boldsp'>1</span>间" + " x <span class='redsp'>" +hotel_rate;
                    }else if(i>2 && i<=4){
                        other_price = hotel_price*2 + ticket_price*i;
                        text += hotel_total_cost + "</span> x <span class='boldsp'>2</span>间" + " x <span class='redsp'>" +hotel_rate;
                    }else{
                        other_price = hotel_price*3 + ticket_price*i;
                        text += hotel_total_cost + "</span> x <span class='boldsp'>3</span>间" + " x <span class='redsp'>" +hotel_rate;
                    }
                    text += "</span>) + (<span class='boldsp'>";

                    text += ticket_total_cost+"</span> x <span class='boldsp'>"+i+"</span>人" + " x <span class='redsp'>" +ticket_rate+"</span>) ";
                    text += " + (<span class='boldsp'>"+extra_total_cost+"</span> x <span class='redsp'>"+extra_rate+"</span>)"+"】 / "+i;

                    var sale_price = vehicle_price + other_price + extra_price;
                    sale_price = Math.ceil(sale_price/i);

                    html += '<tr>' +
                        '<th>' +
                        '<input type="hidden" class="people_num" value="'+i+'">' +
                        '<div class="person_name">'+i+'人出行</div>' +
                        '</th>' +
                        '<th><input type="hidden" class="carType" value="'+carTypeCode+'">'+carType+'</th>' +
                        '<th class="minorder_num">'+i+'</th>' +
                        '<th class="inc_order_num">'+i+'</th>' +
                        '<th>'+text+'</th>' +
                        '<th style="width:150px;">' +
                        '<div style="width:10%;float: left;line-height: 40px;">￥</div>' +
                        '<div style="width:85%;float:left;">' +
                        '<input type="hidden" class="vehicle_price" value="'+save_vehicle_cost+'">' +
                        '<input type="hidden" class="hotel_price" value="'+hotel_vehicle_cost+'">' +
                        '<input type="hidden" class="ticket_price" value="'+ticket_vehicle_cost+'">' +
                        '<input type="hidden" class="extra_price" value="'+extra_vehicle_cost+'">' +
                        '<input type="number" readonly class="layui-input person_price" value="'+sale_price+'">' +
                        '</div>' +
                        '</th>' +
                        '</tr>' +
                        '</tr>';
                }
            }else{
                var f_total_sale = Math.ceil(f_cost_sale+extra_price);
                var s_total_sale = Math.ceil(s_cost_sale+extra_price);
                var t_total_sale = Math.ceil(t_cost_sale+extra_price);
                //纯用车
                head_html = '<tr><th>车型</th><th>【包车*<span class="redsp">利率</span>+额外费用*<span class="redsp">利率</span>】</th><th>售卖价格</th></tr>';
                html = '<tr>' +
                    '<th class="person_name">5座车</th>' +
                    '<th>【('+f_cost+'*<span class="redsp">'+vehicle_rate+'</span>) + ('+extra_total_cost+'*<span class="redsp">'+extra_rate+'</span>)】</th>' +
                    '<th>' +
                    '<div style="width:5%;float: left;line-height: 40px;">￥</div>' +
                    '<div style="width:92%;float:left;">' +
                    '<input type="hidden" class="carType" value="1">' +
                    '<input type="hidden" name="vehicle_cost" value="'+f_cost+'">' +
                    '<input type="hidden" name="extra_cost" value="'+extra_total_cost+'">' +
                    '<input type="number" id="5_sale_s" readonly class="layui-input person_price" value="'+f_total_sale+'" />' +
                    '</div>' +
                    '</th>' +
                    '</tr>' +
                    '<tr>' +
                    '<th class="person_name">7座车</th>' +
                    '<th>【('+s_cost+'*<span class="redsp">'+vehicle_rate+'</span>) + ('+extra_total_cost+'*<span class="redsp">'+extra_rate+'</span>)】</th>' +
                    '<th>' +
                    '<div style="width:5%;float: left;line-height: 40px;">￥</div>' +
                    '<div style="width:92%;float: left;">' +
                    '<input type="hidden" class="carType" value="10">' +
                    '<input type="hidden" name="vehicle_cost" value="'+s_cost+'">' +
                    '<input type="hidden" name="extra_cost" value="'+extra_total_cost+'">' +
                    '<input type="number" id="7_sale_s" readonly class="layui-input person_price" value="'+s_total_sale+'" />' +
                    '</div>' +
                    '</th>' +
                    '</tr>' +
                    '<tr>' +
                    '<th class="person_name">12座车</th>' +
                    '<th>【('+t_cost+'*<span class="redsp">'+vehicle_rate+'</span>) + ('+extra_total_cost+'*<span class="redsp">'+extra_rate+'</span>)】</th>' +
                    '<th>' +
                    '<div style="width:5%;float: left;line-height: 40px;">￥</div>' +
                    '<div style="width:92%;float: left;">' +
                    '<input type="hidden" class="carType" value="20">' +
                    '<input type="hidden" name="vehicle_cost" value="'+t_cost+'">' +
                    '<input type="hidden" name="extra_cost" value="'+extra_total_cost+'">' +
                    '<input type="number" id="12_sale_s" readonly class="layui-input person_price" value="'+t_total_sale+'" />' +
                    '</div>' +
                    '</th>' +
                    '</tr>';
            }

            $("#specs_head").html(head_html);
            $("#specs_body").html(html);
        }
        //提交
        function saveVehiclePackageData(package_id,date,more_time){
            //记录数据
            var postData = {};
            var mydata = null;
            var more_btn = $("#more_btn").attr("data-id");//是否为纯包车

            //组装person列表
            var hotels = [];
            var specs = [];
            var personlist = $("#specs_body tr");
            if(more_btn==1){
                $(".hotelCost").each(function(){
                    var hotel = {};
                    hotel.hotelCost = $(this).val();
                    hotel.hotelCostToPrice = $(this).parent().find(".hotelCostToPrice").attr("value");
                    hotels.push(hotel);
                });

                $.each(personlist,function(i,v){
                    var spec = {};
                    spec.num = $(v).find(".people_num").val();
                    spec.name = $(v).find(".person_name").text();
                    spec.carType = $(v).find(".carType").val();
                    spec.minorder_num = $(v).find(".minorder_num").text();
                    spec.inc_order_num = $(v).find(".inc_order_num").text();
                    spec.price = $(v).find(".person_price").val();
                    spec.vehicle_price = $(v).find(".vehicle_price").val();
                    spec.hotel_price = $(v).find(".hotel_price").val();
                    spec.ticket_price = $(v).find(".ticket_price").val();
                    spec.extra_price = $(v).find(".extra_price").val();
                    specs.push(spec);
                });
            }else{
                $.each(personlist,function(i,v){
                    var spec = {};
                    spec.num = 1;
                    spec.name = $(v).find(".person_name").text();
                    spec.carType = $(v).find(".carType").val();
                    spec.minorder_num = 1;
                    spec.inc_order_num = 1;
                    spec.price = $(v).find(".person_price").val();
                    spec.vehicle_price = $(v).find("input[name=vehicle_cost]").val();
                    spec.extra_price = $(v).find("input[name=extra_cost]").val();
                    specs.push(spec);
                });
            }

            postData.specs = specs;
            postData.hotels = hotels;
            postData.date = date;
            //组装时间集合
            postData.package_id = package_id;
            postData.more_time = more_time;
            postData.more_btn = more_btn;
            var param = JSON.stringify(postData);
            var shadowindex = layer.load(1); //添加laoding,0-2两种方式
            $.post("/admin/product/setVehicleProductPrice",{param},function(data){
                layer.close(shadowindex);
                layer.msg(data.msg);
                if(data.code==200){
                    setTimeout(function(){
                        window.location.reload();
                    },1500);
                }
            },'json');
            return mydata;
        }

        //初始化时配置车型派单价
        function setCarPrice(){
            var exchangeNum = $("#exchangeNum").attr("value");
            exchangeNum = parseFloat(exchangeNum);
            var f_cost_currency = $("#5_cost_currency").val();
            var s_cost_currency = $("#7_cost_currency").val();
            var t_cost_currency = $("#12_cost_currency").val();
            f_cost_currency = Number(f_cost_currency);
            s_cost_currency = Number(s_cost_currency);
            t_cost_currency = Number(t_cost_currency);
            var f_cost =  Math.round(f_cost_currency*exchangeNum*100)/100;
            var s_cost =  Math.round(s_cost_currency*exchangeNum*100)/100;
            var t_cost =  Math.round(t_cost_currency*exchangeNum*100)/100;
            $("#5_cost").attr("value",f_cost);
            $("#7_cost").attr("value",s_cost);
            $("#12_cost").attr("value",t_cost);
            createSpecs();
        }

        //酒店门票成本启用&关闭    按钮
        $("#more_btn").click(function(){
            var dataid = $(this).attr("data-id");
            if(dataid==1){
                $(this).attr("data-id",0);
                $(".more_cost_li").hide();
                $(this).addClass("layui-btn-danger");
                $(this).text("未使用");
            }else{
                $(this).attr("data-id",1);
                $(".more_cost_li").show();
                $(this).removeClass("layui-btn-danger");
                $(this).text("启用中");
            }
            createSpecs();

            return false;
        });



        $(".showProductBasePackage").click(function(){
            var product_id = $("#tripid").val();
            layer.open({
                type:2,
                content:"{:url('admin/product/setProductBasePrice')}?id="+product_id,
                title:'{:lang("设置产品套餐价格")}',
                area:['90%','90%'],
                shade: [0.8, '#393D49'],
                end:function(){
                    window.location.reload();
                }
            })
            return false;//禁止button提交
        })
        $(".showProductBasePackageRate").click(function(){
            var product_id = $("#tripid").val();
            layer.open({
                type:2,
                content:"{:url('admin/product/setbasepackagerate')}?id="+product_id,
                title:'{:lang("设置产品套餐价格")}',
                area:['90%','90%'],
                shade: [0.8, '#393D49'],
                end:function(){
                    window.location.reload();
                }
            })
            return false;//禁止button提交
        })

        //推荐产品
        form.on('select(allRecommendStandard)',function (data) {
            var standardId = data.value;
            var standardName = $('#allRecommendStandard option:selected').text();
            var selectedStandardIds = $("input[name=recommend_standard_ids]").val();
            if(selectedStandardIds=='' ||selectedStandardIds==undefined){
                $("input[name=recommend_standard_ids]").val(standardId);
            }else{
                selectedStandardIds = selectedStandardIds.split(',');
                if($.inArray(standardId,selectedStandardIds) > -1){
                    layer.msg('请勿重复选择！');return false;
                }else if(selectedStandardIds.length >= 5){
                    layer.msg('最多可推荐5款产品！');return false;
                }else{
                    selectedStandardIds.push(standardId);
                    $("input[name=recommend_standard_ids]").val(selectedStandardIds.join(","));
                }
            }
            //添加展示元素
            $("#selectedRecommendStandard").append('<span class="layui-btn layui-btn-sm layui-btn-normal delRecommendStandard" data-id="'+ standardId +'" style="margin: 5px 10px">'+ standardName +'<i class="layui-icon"></i></span>');
            return false;
        })

        //删除推荐产品
        $(document).on('click','.delRecommendStandard',function (e) {
            var standardId = $(this).attr('data-id');
            var selectedStandardIds = $("input[name=recommend_standard_ids]").val();
            if(selectedStandardIds!=='' || selectedStandardIds!==undefined){
                selectedStandardIds = selectedStandardIds.split(',');
                var index = $.inArray(standardId,selectedStandardIds);
                if(index > -1){
                    selectedStandardIds.splice(index,1);
                    if(selectedStandardIds.length < 1){
                        selectedStandardIds = "";
                    }else{
                        selectedStandardIds = selectedStandardIds.join(",");
                    }
                    $("input[name=recommend_standard_ids]").val(selectedStandardIds);
                }
            }
            $(this).remove();return false;
        })

            //新增客户信息模块
            function addCustomerAttrsModuleForm(data_str,name,en_name,is_disabled,is_show)
            {
                var disabled = is_disabled > 0 ? 'disabled' : '';
                var show = is_show > 0? 'checked' : '';
                var html = '<input class="layui-input-inline" type="checkbox" value="'+ data_str +'" lay-filter="selectCustomerAttr" lay-skin="primary" title="'+ name +'" '+ show +' '+ disabled +'>\n';
                $('#customerAttrs').append(html);
            }
            //新增客户信息模块
            function addCustomerInfoModuleForm(index,data_str,name,en_name,is_disabled,is_req,is_master)
            {
                var req_checked = is_req > 0 ? 'checked' : '';
                var disabled = is_disabled > 0 && is_master > 0 ? 'disabled' : '';
                var html = '<div class="layui-inline selectedAttr"><form class="layui-form">\n' +
                    '                                    <input type="hidden" value="'+data_str+'" class="customerData layui-input layui-input-inline">\n' +
                    '                                    <input type="text" readonly disabled value="'+name+'" class="customerTitle layui-input layui-input-inline">\n' +
                    // '                                    <input type="text" readonly value="'+en_name+'" class="customerEnTitle layui-input layui-input-inline">\n' +
                    '                                    <input '+ disabled +' type="checkbox" lay-skin="switch" data-master="'+ is_master +'" data-index="'+ index +'" value="1" '+req_checked+' class="customerReq layui-input layui-input-inline" lay-filter="changeCusReq" lay-text="必填|选填">\n' +
                    '                                </form></div>';
                var customerInfo = is_master > 0 ?
                    '.selectedMasterCustomerInfo' : '.selectedSecondCustomerInfo' ;
                return $(customerInfo).append(html);
            }

            function initCustomerAttrs()
            {
                var customerAttrs = "{$customerAttrs}";
                var customerAttrs = customerAttrs.split(',');
                $.each(customerAttrs,function (i,v) {
                    if(v.length < 1){return true;}
                    var value = v.split('-');
                    var name = value[0] || '';
                    var en_name = value[1] || '';
                    var is_disabled = value[2] || 0;
                    var is_show = value[3] || 0;
                    addCustomerAttrsModuleForm(v,name,en_name,is_disabled,is_show);
                })
            }
            function renderCustomerInfoConfig(proCustomerAttrs)
            {
                $.each(proCustomerAttrs,function (i,v) {
                    if(v.length < 1){return true;}
                    var value = v.split('-');
                    var name = value[0] || '';
                    var en_name = value[1] || '';
                    var is_disabled = parseInt(value[2]) || 0;
                    var is_req = parseInt(value[4]) || 0;
                    addCustomerInfoModuleForm(i,v,name,en_name,is_disabled,is_req,1);
                    var is_req = parseInt(value[5]) || 0;
                    addCustomerInfoModuleForm(i,v,name,en_name,is_disabled,is_req,0);
                })
                form.render();
            }
            function initCustomerInfoConfig()
            {
                initCustomerAttrs();
                var proCustomerAttrs = "{$customerInfoConfig}";
                var proCustomerAttrs = proCustomerAttrs.split(',');
                renderCustomerInfoConfig(proCustomerAttrs)
            }
            initCustomerInfoConfig();

            //获取客户信息模块内容
            function getCustomerInfoModuleData()
            {
                var checkedCustomerAttrs = $("#customerAttrs input:checked");
                var masterCustomerReq = $(".selectedMasterCustomerInfo .selectedAttr");
                var secondCustomerReq = $(".selectedSecondCustomerInfo .selectedAttr");
                var customer_info_config = [];
                $.each(checkedCustomerAttrs,function (i,v) {
                    var attr = $(v).val();
                    var attr_arr = attr.split('-');
                    console.log()
                    attr_arr[4] = $(masterCustomerReq[i]).find('.layui-form-onswitch').length > 0 ? 1 : 0;
                    attr_arr[5] = $(secondCustomerReq[i]).find('.layui-form-onswitch').length > 0 ? 1 : 0;
                    customer_info_config.push(attr_arr.join('-'));
                })
                return customer_info_config.join(',');
            }
            form.on('checkbox(selectCustomerAttr)',function(data){
                //修改当前的数据
                var is_checked = data.elem.checked ? 1 : 0;
                var attr = $(this).val();
                attr = attr.split('-');
                attr[3] = is_checked;
                $(this).val(attr.join('-'));

                var proCustomerAttrs = [];
                var checkedCustomerAttrs = $('#customerAttrs input:checked');
                $.each(checkedCustomerAttrs,function (i,v) {
                    proCustomerAttrs.push($(v).val())
                })
                $('.selectedMasterCustomerInfo').children().remove();
                $('.selectedSecondCustomerInfo').children().remove();
                renderCustomerInfoConfig(proCustomerAttrs);
                autoUpdateCustomerInfoModule();
            })

            //必填开关
            form.on('switch(changeCusReq)',function(data){
                var is_checked = data.elem.checked ? 1 : 0;
                var index = $(this).attr('data-index');
                var master = $(this).attr('data-master');
                var customerAttr = $($('#customerAttrs input[type=checkbox]:checked')[index]).val();                
                customerAttr = customerAttr.split('-');
                if(master > 0){
                    customerAttr[4] = is_checked;
                }else{
                    customerAttr[5] = is_checked;
                }
                customerAttr = customerAttr.join('-');
               

                $($('#customerAttrs input[type=checkbox]:checked')[index]).val(customerAttr);
                autoUpdateCustomerInfoModule();
            })
            form.on('radio(changeAllCustomerReq)',function(data){
                console.log(data.value);
                changeDisplaySecondCustomerInfo(data.value);
                var product_id = $("#tripid").val();
                autoUpdateProductInfo({id:product_id,all_customer_req:data.value})
            })

            function changeDisplaySecondCustomerInfo(value)
            {
                value > 0 ?
                    $('#secondCustomerInfo').show() :
                    $('#secondCustomerInfo').hide();
            }

            //初始化显示次出行人信息
            {if $product.all_customer_req > 0}
            changeDisplaySecondCustomerInfo(1);
            {else}
            changeDisplaySecondCustomerInfo(0);
            {/if}

            function autoUpdateCustomerInfoModule()
            {
                var proCustomerAttrs = [];
                var checkedCustomerAttrs = $('#customerAttrs input:checked');
                $.each(checkedCustomerAttrs,function (i,v) {
                    proCustomerAttrs.push($(v).val())
                })
                var product_id = $("#tripid").val();
                var customer_info_config = proCustomerAttrs.join(',');
                autoUpdateProductInfo({id:product_id,customer_info_config:customer_info_config})
            }
    });
</script>
<script>
    var sale_details_toolbars = [
        [
            'anchor', //锚点
            'undo', //撤销
            'redo', //重做
            'bold', //加粗
            'indent', //首行缩进
            'italic', //斜体
            'source', //源代码
            'pasteplain', //纯文本粘贴模式
            'removeformat', //清除格式
            'unlink', //取消链接
            'cleardoc', //清空文档
            'fontfamily', //字体
            'fontsize', //字号
        ],[
            'simpleupload', //单图上传
            'insertimage', //多图上传
            'link', //超链接
            'justifyleft', //居左对齐
            'justifyright', //居右对齐
            'justifycenter', //居中对齐
            'justifyjustify', //两端对齐
            'forecolor', //字体颜色
            'backcolor', //背景色
            'fullscreen', //全屏
            'attachment', //附件
            'imagecenter', //居中
        ]
    ];

    function saveSaleDetails(){
        var content =(sale_details.getContent());
        autoUpdateSaleDetails(content);
    }
    function autoUpdateSaleDetails(content)
    {
        var product_id = $("#tripid").val();
        var param = {};
        if(content!='' && content!=undefined){
            param.id = product_id;
            param.sale_details = content;
            autoUpdateProductInfo(param);
        }
    }

    function replaceWxImageFunc(str)
    {
        var reg_URL = 'https://www.kuaibangxing.com/transition\\?img=';
        var URL= 'https://www.kuaibangxing.com/transition?img=';
        str = str.replace(RegExp(reg_URL, 'g'),'');
        str = str.replace(RegExp('http://mmbiz.qpic.cn/', 'g'),URL + 'http://mmbiz.qpic.cn/');
        str = str.replace(RegExp('https://mmbiz.qpic.cn/', 'g'),URL + 'https://mmbiz.qpic.cn/');
        return str;
    }

    function removeRepeatSection(str)
    {
        return str.replace(/(<section>|<\/section>)\1{1,}/g,'$1');
    }

    function replaceWxImageUrl(o, html,editor_name) {
        var str = UE.getEditor(editor_name).getContent();
        str = replaceWxImageFunc(str);
        str = removeRepeatSection(str);
        UE.getEditor(editor_name).setContent(str);
        UE.getEditor(editor_name).focus(true);
    }
    function replaceTextPlanWxImageUrl(o, html) {
        replaceWxImageUrl(o, html.html,'text_plan')
    }
    function replaceSaleDetailsWxImageUrl(o, html) {
        replaceWxImageUrl(o, html.html, 'sale_details')
    }

    {if $textPlan}
    var text_plan = UE.getEditor('text_plan', { initialFrameWidth: null , autoHeightEnabled: true , toolbars:sale_details_toolbars});
    function saveTextPlan(){
        var content =(text_plan.getContent());autoUpdateTextPlan(content)
    }
    function autoUpdateTextPlan(content)
    {
        var product_id = $("#tripid").val();
        var param = {};
        if(content!='' && content!=undefined){
            param.id = product_id;
            param.text_plan = content;
            autoUpdateProductInfo(param);
        }
    }
    UE.getEditor('text_plan').addListener('afterpaste',replaceTextPlanWxImageUrl);

    {else}
    var sale_details = UE.getEditor('sale_details', { initialFrameWidth: null , autoHeightEnabled: false , toolbars:sale_details_toolbars});
    $('.createSalesContent').click(function () {
        layer.confirm('是否确认使用线路方案生成售卖详情？',function () {
            var loading = layer.load(2);
            var id = {$tripid} || 0;
            $.post("{:url('admin/product/createProductSalesContent')}",{id:id},function (res) {
                layer.close(loading);
                layer.msg(res.msg);
                if(res.code > 0){
                    console.log(res.data.content);
                    UE.getEditor('sale_details').setContent('');//先清空内容
                    UE.getEditor('sale_details').execCommand('insertHtml',res.data.content);
                }
            },'json')
        })
    })
    UE.getEditor('sale_details').addListener('afterpaste', replaceSaleDetailsWxImageUrl);

    {/if}
</script>
<script>
    //JS监听关闭浏览器事件
    //关键字: js监听关闭浏览器事件
    //Onunload与Onbeforeunload
    //Onunload，onbeforeunload都是在刷新或关闭时调用，可以在<script>脚本中通过window.onunload来指定或者在<body>里指定。
    //区别在于onbeforeunload在onunload之前执行，它还可以阻止onunload的执行。
    //Onbeforeunload也是在页面刷新或关闭时调用，Onbeforeunload是正要去服务器读取新的页面时调用，此时还没开始读取；而onunload则已经从服务器上读到了需要加载的新的页面，在即将替换掉当前页面时调用。Onunload是无法阻止页面的更新和关闭的。而 Onbeforeunload 可以做到。
    window.onbeforeunload = onbeforeunload_handler;
    window.onunload = onunload_handler;
    function onbeforeunload_handler(){
        //执行产品详情自动保存
        //saveSalesDetailsAndTextPlan()
    }

    function onunload_handler(){
        //执行产品详情自动保存
        //saveSalesDetailsAndTextPlan()
    }
    //每隔5分钟产品详情自动保存
    var $second = 5*60;
    setInterval(function () {
        saveSalesDetailsAndTextPlan()
    },$second*1000);
    //点击按钮保存产品详情
    $('.saveSalesDetails').click(function () {
        layer.load(2);
        showAutoUpdateMsg = true;
        saveSaleDetails();
    })
    //点击按钮保存产品详情
    $('.saveTextPlan').click(function () {
        layer.load(2);
        showAutoUpdateMsg = true;
        saveTextPlan();
    })
    //合并保存详情和文本
    function saveSalesDetailsAndTextPlan()
    {
        var product_id = $("#tripid").val();
        var param = {};
        var sale_content = plan_content = '';
        {if $textPlan}
        plan_content = (text_plan.getContent());
        {else}
        sale_content = (sale_details.getContent());
        {/if}
        if(sale_content!='' && sale_content!=undefined){
            param.sale_details = sale_content;
        }
        if(plan_content!='' && plan_content!=undefined){
            param.text_plan = plan_content;
        }
        if(Object.keys(param).length>0){
            param.id = product_id;
            autoUpdateProductInfo(param);
        }
    }
</script>

</body>
</html>